Adding Custom Post Types to RSS feed
-
Looking to add CPTUI custom post types to my main RSS feed. I was able to find a tutorial and it works, kinda but the RSS feed changes every time i check it, old posts show up and incorrect order. This is for mailchimp.
Tutorial: https://docs.pluginize.com/article/148-how-to-add-your-custom-post-type-to-rss-feeds
My Feed:https://www.snyder-associates.com/category/transportation/feed/
function my_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(‘snyder-projects’);$query->set(
‘post_type’,
array_merge(
array( ‘post’ ),
$cptui_post_types
)
);
}
add_filter( ‘pre_get_posts’, ‘my_cptui_add_post_types_to_rss’ );
The topic ‘Adding Custom Post Types to RSS feed’ is closed to new replies.