0

So this is what I have done for my homepage so I load css that only loads on my homepage

    function enqueue_frontend_assets(){
    if(is_page_template( 'homepage.php')) {
        wp_enqueue_style( 'homepage',  get_template_directory_uri().'/assets/css/homepage.css' );
    }
}

And it works just fine and only loads on the homepage.

I am trying to load the exact same file for my custom taxonomy page but it doesn't load.

    function enqueue_frontend_assets(){
    if(is_page_template( 'taxonomy-state.php')) {
        wp_enqueue_style( 'homepage',  get_template_directory_uri().'/assets/css/homepage.css' );
    }
}

What should I use instead to make sure it loads on all the custom taxonomy pages?

1 Answer 1

2

Instead of checking against the template, you should use is_tax() which is one of the conditional tags in WordPress.

So in your function, you just need to use is_tax( 'state' ) in place of is_page_template( 'taxonomy-state.php'), and your asset would only be loaded on the archive page for your custom state taxonomy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.