WordPress.org

Ready to get started?Download WordPress

Forums

RSS Feed with Query from conditional custom feed (1 post)

  1. kettlewell
    Member
    Posted 2 years ago #

    I have several posts that have custom field's attached to them that I don't want to show up in the RSS feed.

    This is my attempt, but somethings not right...

    function ke_rss_exclude_filter($query) {
      if ( !$query->is_admin && $query->is_feed) {
      $meta_group = array (
         'relation' => 'OR',
                        array(
    			'key' => 'exclude1',
    			'value' => 'crit1',
    			'compare' => 'NOT IN'
                             ),
                        array(
    			'key' => 'exclude2',
    			'value' => 'crit2',
    			'compare' => 'NOT IN'
                             ),
    			);
        $query->set( 'meta_query', $meta_group  );
      }
      return $query;
    }
    
    add_filter( 'pre_get_posts', 'ke_rss_exclude_filter' );

    I think I'm getting confused on several similar functions and functionality, and just need some pointers on pulling it all together.

    All help / comments appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic