I have two functions to enqueue my scripts. I want to call one function if the post is a custom post type, and the other for all other posts and pages.
How add conditional logic in functions.php to do this? Typical Wordpress functions(get_the_ID, is_post_type and others) are not working in functions.php.
This is my code:
// How Add Conditional Logic ?
add_action( 'wp_enqueue_scripts', 'theme_media_new' );
// Use fot All pages to site
function theme_media() {
wp_enqueue_style( 'main-css', get_template_directory_uri() . '/static/css/main.min.css"' );
wp_enqueue_script( 'common-js', get_template_directory_uri() . '/static/js/main.js', array(), '1.0.0', true );
}
// Use Only for custom post type 'coaching'
function theme_media_new(){
wp_enqueue_style( 'main-new-css', get_template_directory_uri() . '/static_new/css/main.min.css"' );
wp_enqueue_script( 'common-new-js', get_template_directory_uri() . '/static_new/js/main.min.js', array(), '1.0.0', true );
}