How to include custom posts in post RSS in WordPress

avatar
Share This:

Put the following code in functions.php. For example, if it is a slug for a custom post type called ‘product’ or ‘wpdmpro’, enter it as follows. Replace slug with your own custom post type slug.

/* Include custom posts in post RSS */
add_filter( 'pre_get_posts', 'my_custom_posts_rss' );
function my_custom_posts_rss( $query ) {
if ( is_feed() )
$query->set( 'post_type', array( 'post', 'product', 'wpdmpro' ) );
return $query;
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

thirteen − 11 =