有很多方法可以将自定义帖子类型添加到RSS提要中,但我似乎找不到一种方法可以将CPT UI
插件自定义帖子类型增加到custom post TYPE独占RSS提要中以仅查询这些帖子。
有办法做到这一点吗?
试试看:
function cptui_add_post_types_to_rss( $query ) {
// We do not want unintended consequences.
if ( ! $query->is_feed() ) {
return;
}
// Replace these slugs with the post types you want to include.
$cptui_post_types = array( 'my_post_type', 'my_other_post_type' );
$query->set(
'post_type',
array_merge(
array( 'post' ),
$cptui_post_types
)
);
}
add_filter( 'pre_get_posts', 'cptui_add_post_types_to_rss' );