Why doesnt this work ? I am trying to selectively load scripts but the second if statement is not loading them where it should.
function my_init() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js', false, '1.5');
wp_enqueue_script('jquery');
if (in_category('41') ) {
wp_register_script('validator', '/wp-content/themes/myTheme/library/jquery.validationEngine.js', array('jquery'), '2.0', false);
wp_enqueue_script('validator');
wp_register_script('vEngine', '/wp-content/themes/myTheme/library/jquery.validationEngine-en.js', array('validator'), '2.0', false);
wp_enqueue_script('vEngine');
}
}
}
add_action('init', 'my_init');
If I remove the second if statement for that category it works but I want to restrict it to a single category or even an is_single('123')
What am I doing wrong?