wp_enqueue_script with add_action('init')
-
Hi there,
I want to enqueue some scripts and styles on the ‘init’ action, but only if a certain condition is met i.e the user is viewing a category page with an ID of 12. I’ve tried a couple of things to get it to work but am having no luck ?? Below is some sample code from my functions.php file:
function the_quote_files() { if(is_category(12)) { wp_enqueue_script(<args here); ... more scripts and styles ... } } add_action('init','the_quote_files');
I just can’t seem to get it to fire, I’ve also tried using get_query_var(‘cat’) to no avail.
My only guess as to why it isn’t working is when the ‘init’ action is happening, no data has been processed.
Does anyone know how I can get the scripts to load only when the user is viewing a certain category archive page?
Thanks, Andy
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘wp_enqueue_script with add_action('init')’ is closed to new replies.