• Hi all

    I’m new to the plugin architecture but as I understand this all plugins run on all page impression?

    I have a page called ‘add’ and I want my plugin on this page – only. I can do this by createing a template tag and add that to the page template, but it feels wrong to parse all my plugin code on every page load, in the admin and everyware?

    I have tryied using the ‘is_page(‘add’)’ but that seems to work only in templates?

    Please some advice / Johannes

Viewing 1 replies (of 1 total)
  • Hi Johannes,
    If you want to ensure that your plugin doesn’t load in admin test of is_admin(). You could put chunks of your code inside that conditional (or the !is_admin() conditional) or if you don’t have any settings at all in the admin, just put if ( is_admin() ) { return; } at the top of your plugin file.

    Also, you could use is_page(‘add’) in your plugin code as well. You may just need to add it to a hook that fires off after template redirect:

    add_action('template_redirect','your_function');
    function your_function(){
     if ( is_page('add') ) {
      // do you thing.
     }
    }

    Hope that helps or gives you an idea.

Viewing 1 replies (of 1 total)
  • The topic ‘Use is_page in plugin – how to?’ is closed to new replies.