Can someone tell me whether it is possible to create a plugin that is only available to a specific theme and how do I override certain settings in that theme?

The problem This is basically the story. We've had a third party design and create a wordpress theme for us. Now it's up to us to expand the functionality of the theme by creating a plugin that will only be valid when someone has our theme installed.

Are there specific functions available to achieve this?

Thanks in advance.

  • If it's so tied to the theme, why not use functions.php? – Stephen Harris Jun 12 '14 at 12:06
  • Well, it's not tied to theme yet, my question is basically: how do I tie it to the theme? – NextGDev Jun 12 '14 at 12:12
  • Is this a third-party plug-in? If not, just bundle it into functions.php... – Stephen Harris Jun 12 '14 at 12:35
  • Well, we're designing it so it will only work with that specific theme; which we are also (together with an other party) in control of. – NextGDev Jun 12 '14 at 12:57

You can ask for the activation of the theme. You can get the value of the options values templateand stylesheet. The stylesheet get the active style, a benefit if the user use an child theme. As example if ( 'my_theme' === get_option( 'stylesheet' ) ) ....

Also you can use the hooks for template and stylesheet, also s small exmaple.

add_filter( 'option_template', 'fb_theme' );
add_filter( 'option_stylesheet', 'fb_theme' );
function fb_theme( $template = '' ) {

    if ( 'my_theme' === $template ) {
        echo 'TRUE';

    return $template;
  • Thanks for this. I understand that I can basically override functions by adding functions to my plugin function.php file, correct? – NextGDev Jun 12 '14 at 12:32
  • This is a other question. My answer give you a solution to get the active theme of the users. But to override a function, like from core, theme or plugin is much more to do. If the functions inside theme have a hook or a if ( function_exists( 'test_func' ) ), then it is often possible. – bueltge Jun 12 '14 at 12:33

Your Answer

