Quantcast
Channel: Wordpress RSS feed template with custom wp_query - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Rokas for Wordpress RSS feed template with custom wp_query

$
0
0

Ok, so I figured out that you cannot use custom loops in rss template, you need to filter feed in pre_get_posts.

You can pass any parameter to $query object, for example:

feed_filter($query){    if( $query->is_feed && $query->is_main_query() )    {        $query_args = array('relation' => 'OR',                array('key' => 'votes','value' => '10','compare' => '>=','type' => 'NUMERIC',                ),                array('key' => 'author_role','value' => array('administrator', 'contributor', 'editor', 'author'),'compare' => 'IN',                )        );        $query->set( 'meta_query', $query_args );    }}add_action( 'pre_get_posts', 'feed_filter' );

Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>