Archived topic
RSS Feed - Feed for Post type "page"
1 reply · Started by Stephan Schramm on August 14, 2022
Dear all,
my homepage has only pages so far. However, I would like to create a RSS feed. I understand that with wordpress this is not possible. Therefore I have inserted the following code through a snippet:
/**
********************
* CHANGES TS
********************
*
* Add RSS Feed for Pages
*/
add_action( 'pre_get_posts', 't5_pages_in_feed' );
/**
* Set post type to 'page' if it was requested.
*
* @param object $query
* @return void
*/
function t5_pages_in_feed( &$query )
{
if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] === 'page' && is_feed() )
{
$query->set( 'post_type', 'page' );
$post_ids = array(8, 3, 2086);
$query->set('post__not_in', $post_ids);
}
}
Unfortunately, it still does not work. I have tried to reach the RSS via the following address:
https://asiaversum.de/feed/?post_type=page
Can you support me?
Many thanks in advance
STephan
Hi Stephan,
Unfortunately this is not a theme/GP-related question at all so it's out of the scope of this support forum:
https://generatepress.com/what-support-includes/
I would recommend checking with WordPress' support team as the pre_get_posts is a WP core filter.
Or post your question in a general WordPress forum like this:
https://wordpress.stackexchange.com/
Hope this helps :)