admin管理员组文章数量:1426012
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.
本文标签: How to Implement Custom Taxonomy Conditional Page
版权声明:本文标题:How to Implement Custom Taxonomy Conditional Page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745464206a2659459.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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