I want to create custom taxonomy conditional page. My post type is "laptops".

My current code dose not working. But this code work for post_type "post" section.

add_filter( 'template_include', 'mobile_laptop_category_page_template', 99 );
function mobile_laptop_category_page_template( $template ) {
    if ( wp_is_mobile() && is_taxonomy() && 'laptops' == get_post_type()) {
        $new_template = locate_template( array( '/mobile/category/taxonomy-routers.php' ) );
        if ( '' != $new_template ) {
            return $new_template ;
    return $template;

1 Answer 1


For custom taxonomy template you can create a php file in your child theme with name "taxonomy-[taxname].php for example taxonomy-laptops.php. This template will be use for any post type that contains taxonomy laptops. In taxonomy-laptops.php you could use a condtional like if post type is laptops then do something else something else.

I hope this could help you, i m a little confused with the querstion.

  • Your answer right for desktop version. But i want to create different taxonomy archive page. This taxonomy archive page only for mobile version. Commented May 28, 2019 at 12:22

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.