I’m in a bad mood today, so I’m gonna do a little whining about WordPress theme frameworks, okay? Don’t be surprised if I delete this post in a day or two ;)
I was reading this post on WPBeginner, where Syed writes that you can edit your theme’s header.php file, and add a stylesheet for a Google Font in your theme. Then he writes about “the right way” to do it in the Genesis theme framework:
add_action( 'genesis_meta', 'wpb_add_google_fonts', 5);
function wpb_add_google_fonts() {
echo '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Lora|Oswald" media="screen">';
}
Okay, so here’s what I don’t understand. Why on earth should a theme framework way of adding a stylesheet file, differ from the WordPress way to do it?
I spent years and years and years, studying the massive amount of WordPress actions and filters, and by now I’m aware that if I’d like to output something in my theme’s <head> section, I’d simply use a child theme functions.php file, or a plugin file (I wouldn’t edit my header.php), and hook to wp_head to print my link elements, voila!
Now if I choose to use Genesis (or any other theme framework for that matter), it’s supposed to make my life easier, right? Well no! Now I have to spend more and more years to study another billion actions and filters names, so I know that if I’m using Genesis, I have to hook to genesis_meta instead. This is crazy, and the reason why I don’t use any WordPress theme frameworks. Please don’t come and tell me your framework is different and I’m gonna love it, because I’m not.
Oh and in case you were wondering, the right way to include a stylesheet into your WordPress theme would be to use the wp_enqueue_style function.
Phew, I feel much better.