If you build WordPress themes you’ll already be familiar with enabling features using
add_theme_support. This function provides an easy means to enable optional features on a per theme basis – WordPress’ custom logo, custom background, title tag support and many more.
It can also be used to extend your theme with custom functionality, and that’s what I want to demonstrate in this post. The example I’m going to use is tweaking a Genesis child theme so that it better supports Beaver Builder.
I’ve done a couple of themes for this client already, and up until now I’ve just added some PHP snippets to the theme
functions.php file to remove excess markup, make the theme full width and remove the page and post titles.
But what I really wanted to do was have this code included in my core functionality plugin, then only switch it on if I want the theme to support Beaver Builder. And this is where
add_theme_support comes in.
Within my core functionality plugin, I added the following:
With this code in my core functionality plugin I can use
add_theme_support( 'generico-beaver-builder' ); within the theme to add my Beaver Builder snippets automatically.
The result is cleaner code within Beaver Builder pages, with excess markup and page titles removed, and much cleaner code in my theme. And the same principle could be applied to any number of other uses.