Add products or other post types to the RSS feed
Your main RSS feed includes the post types you choose (for example WooCommerce products) as well as posts.
Before you switch it on: List the post types you want in array( 'post', 'product' ).
It arrives switched off, even when you install its whole pack with "Switch on after installing".
<?php
add_action(
'pre_get_posts',
static function ( $query ) {
if ( $query->is_main_query() && $query->is_feed() && ! $query->get( 'post_type' ) ) {
$query->set( 'post_type', array( 'post', 'product' ) );
}
}
);
In these packs
- RSS feeds: Control what your RSS feed shows, and when.