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; }
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; }Share Improve this question edited May 25, 2019 at 16:28 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 25, 2019 at 14:19 Alal HossainAlal Hossain 1 3 |
1 Answer
Reset to default 0For 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.
is_taxonomy
is deprecated and it's not a conditional tag. Try usingis_tax()
. Refer to codex.wordpress/Function_Reference/is_tax. – filipecsweb Commented May 25, 2019 at 18:50