This following fails to load the scripts in the single pages,
if(is_single( ) ) add_action('wp_enqueue_scripts', 'build_js');
Suppose, If i use
add_action('wp_enqueue_scripts', 'build_js');
the action is performed and scripts are loaded.
I need to perform the action only on single pages of a custom post type. How to do this?
the problem is you have to check for the single page into the function:
instead of
You can simplify the logic further with the WordPress function
is_singular()
instead.You could include the value of
get_post_type()
in your condition.