• but include it on all other pages & posts.
    sorry, still getting to grips with wp_enqueue & need a solution in a hurry for a client (surprise).

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Json Koning

    (@minion08)

    Ok, so I’ve been looking & still haven’t come up with a solution.
    Anyone?

    Thread Starter Json Koning

    (@minion08)

    So, what I’m trying to do here is enqueue an external script on every page in a site – except – posts in the ‘newsletters’ category.
    The following works with regards to enqueueing the script – but not in excluding the script for all posts in the ‘newsletters’ category.
    Help.
    Please…

    function my_custom_script() {
    
        if ( !is_admin() ) {
    
            /* Enqueue Scripts */
            wp_register_script('autoplay', ('my script goes here')); //first register your custom script
            wp_enqueue_script('autoplay'); // then let wp insert it for you or just delete this and add it directly to your template
        }
        elseif ($category != 'portfolio') {
            wp_deregister_script('autoplay');
        }
    }
    add_action( 'wp_print_scripts', 'my_custom_script'); // now just run the function
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude script from all posts in a certain category…’ is closed to new replies.