Title: Make plugins theme-sensitive?
Last modified: August 18, 2016

---

# Make plugins theme-sensitive?

 *  [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/)
 * Is there a way to make a plugin active only when a particular theme is in use?
 * I hoping to use the features of a paricular plugin, but only when a certain theme
   has been chosen by the visitor. Specifically, a new theme I’m working on would
   be great if only I could just show the most recent post, with links to previous
   posts, on the home page. I’ve tried changing the loop within the theme but ran
   in to trouble as you navigate away from the first page. The plugin:
 * mattread.com/archives/2005/03/custom-query-string-plugin/
 * is great for what I need, but would only want it working in that one theme. It
   would need to not be active for other themes, if I’m to leave theme options for
   visitors.
 * (Original line of thinking was started in this thread: [http://wordpress.org/support/topic/83313?replies=5](http://wordpress.org/support/topic/83313?replies=5),
   thanks dannyb.)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-435889)
 * In your theme, you should have a file called `functions.php`. I think you can
   put any plugins you want to work with your theme in that file. If you look at
   the Kurbic theme, you’ll see functions and that’s how Kurbic allows you the modify
   the header colors.
 * So try putting that plugin (all the PHP of it) inside `functions.php`. I hope
   that works.
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436191)
 * Thanks for the tip tsguitar, but my advice is to NOT try the idea he described
   above. I did, and have develop some strange quirks when trying to create or edit
   posts from the dashboard.
 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436195)
 * Are you sure it’s not a problem with the plugins or some missing code? I’m not
   sure if you’ll need to edit the plugins when you do it, but `functions.php` is
   the place to put additional, well, functions for your theme.
 * Can you list some themes that have plugins included with them? I can take a look
   at how those ones do it and get back to you.
 *  [McShelby](https://wordpress.org/support/users/mcshelby/)
 * (@mcshelby)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436196)
 * Hi I built a theme for myself recently. It’s having a functions.php and inside
   of it includes various other files residing inside the themes subfolder. It also
   contains some plugins and works like a charm (with WP 2.0.2 and WP 2.0.4).
 * The only caveat with this method is, that you can not turn the plugin on/off 
   in the plugin admin panel. It’s just on when you are activating the plugin.
 * This method may also fail if the plugin code assumes it is residing in WPs plugins
   folder. Maybe that’s the case with your issue?
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436249)
 * Maybe I should deactivate the plugin from the dashboard first (?). Or delete 
   it totally from the plugins folder, before trying to add it to the theme functions
   file (?).
 * How would I use the plugins features if it’s not in the WP options pages?
 *  [McShelby](https://wordpress.org/support/users/mcshelby/)
 * (@mcshelby)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436252)
 * If you have the plugin activated in the admin panel AND put it into the theme,
   then you end up including the code two times. If the code is not prepared for
   this, it will generate a horrible amount of PHP errors.
 * With this method you can not activate/deactivate plugins that are stored in the
   themes folder. They are just switched on when you are activating the theme. This
   is not your usually known WP plugin mechanism!
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436259)
 * As long as I don’t kill the whole blog, I think I’ll give it another go.
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436260)
 * Looking at that [custom query string plugin](http://mattread.com/projects/wp-plugins/custom-query-string-plugin),
   I’d say you got lucky. It’s written as a single class. 🙂
 * Down at the bottom of the plugin, you’ll find a line that reads:
    `$cqs = new
   cqs();`
 * Remove that. Then add this to the functions.php of your theme:
    `function themename_load_cqs_plugin(){
   global $cqs; if (class_exists('cqs')) $cqs = new cqs(); } add_action('plugins_loaded','
   themename_load_cqs_plugin');
 * That should do the trick. You can leave the plugin in the plugins folder after
   doing this. Activating and deactivating the plugin via the plugins menu will 
   continue to work properly as well.
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436354)
 * OK- Otto, thanks for the reply. I’m getting an error:
 * `Warning: Cannot modify header information - headers already sent by (output 
   started at .../evilkirk/wp-content/themes/kirkian/functions.php:6) in .../evilkirk/
   wp-admin/plugins.php on line 16`
 * And I’m not exactly sure how this set-up will work in only one theme, but I can’t
   seem to test it as I can’t see the CQS options in the dashboard at this point.
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436355)
 * The above error (which I probably didn’t need to post as ‘code’) is happening
   in the dashboard when I have my test theme active. CQS options do not show whatever
   theme is active…
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436357)
 * An idea: Modifying the CQS plugin itself to give it a ‘theme’ condition? It would
   have to be set up to give you the ability to set sub-conditions after the theme
   condition, I think.
 * I don’t think this is something I can actually do, however. I don’t know enough
   to be dangerous, I know enough to be very dangerous.
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436361)
 * > _Warning: Cannot modify header information – headers already sent by (output
   > started at …/evilkirk/wp-content/themes/kirkian/functions.php:6) in …/evilkirk/
   > wp-admin/plugins.php on line 16_
 * The functions.php file should *never* make any output. You have written it incorrectly.
   Either you have it doing an echo of some kind, or you have empty space outside
   of the <?php … ?> tags, or something.
 * Modify the file to not produce any output and this error will go away.
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436371)
 * I retried the functions thing as a you said, being careful of spaces and format,
   and now the dashboard errors are gone. But CQS options are still nowhere to be
   found. I even tried setting up the options before I changed the functions.php(
   and the line in the plugin), but no go. It just doesn’t seem to want to do it.
 * Maybe if I tried working with the loop again…
 *  Thread Starter [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * (@evilkirk)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436388)
 * Well, I couldn’t get this worked out. A plug-in that makes plug-ins sensitive
   to what theme is in use might be helpful, but there just may not be enough need
   for it. Although not resolved, I would call this issue closed.
 * Thanks for everyone’s ideas.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Make plugins theme-sensitive?’ is closed to new replies.

 * 14 replies
 * 4 participants
 * Last reply from: [evilkirk](https://wordpress.org/support/users/evilkirk/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/make-plugins-theme-sensitive/#post-436388)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
