[英]Wordpress add pages with category to category archive page
I know that category archives are intended for posts. 我知道类别存档是用于帖子的。 But due to some requirements, I also need to assign a category to some pages.
但是由于某些要求,我还需要为某些页面分配一个类别。 And need to add those pages to category archives.
并且需要将这些页面添加到类别存档中。 Does someone know if it's possible?
有人知道这是否可能吗? ps I already managed to assign a category to page.
ps我已经设法为页面分配一个类别。
Thanks @Stender. 谢谢@Stender。 This solved my issue:
这解决了我的问题:
function sbt_exclude_category($query){
if ( $query->is_page('slug') && $query->is_main_query() && ! is_admin() ) {
$query->set( 'post_type', 'any' );
}
}
add_action('pre_get_posts','sbt_exclude_category');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.