其实Custom Post Type UI的帮助里面找得到解决办法,只是太啰嗦了,就直接上干货了
全部直接调用在function.php中加入以下代码:
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );
If you’d like to add only specific post types to listings of tags and categories you can replace the line:
$post_types = get_post_types();
with:
$post_types = array( 'post', 'your_custom_type' );
没有评论:
发表评论