Ok, so I’ve been looking & still haven’t come up with a solution.
Anyone?
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