Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    It’s possible to do all of these things in the snippet code – the frontend and admin controls are just for convenience.

    You can use any of WordPress’ Conditional Tags in your snippet to determine what part of the site the user is currently on.

    You shouldn’t use these conditional tags directly in the body of the snippet, however, but instead in the snippet function. This can vary from snippet to snippet, so if you post a link to your code here I can let you know how to modify it. Here’s an example:

    function my_snippet_function() {
        // Don't run this snippet on page with an ID or 42 or a slug of 'contact-us'
        if ( ! is_page( array( 42, 'contact-us ) ) ) {
            return;
        }
    
        // ... snippet code ...
    }
    
    add_action( 'some_action', 'my_snippet_function' );
    Thread Starter elindydotcom

    (@elindydotcom)

    Hi Shea:

    Thanks for your response – it’s much appreciated. I am not a WP/PHP coder but I get the idea that you’re conveying.

    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Control execution at the page level?’ is closed to new replies.