Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi, this I’ve not seen before. Is there any other plugin that filters feed content or anything like that?

    Thread Starter ezramod

    (@ezramod)

    yes:

    // action
    add_action('pre_get_posts', 'filtru_culturi_posts', 10, 1);
    
    function filtru_culturi_posts( $query ) {
    	
    	// bail early if is in admin
    	if( is_admin() ) return;
    	
    	// bail early if not main query
    	// - allows custom code / plugins to continue working
    	if( !$query->is_main_query() ) return;
    	
    	// get meta query
    	$meta_query = $query->get('meta_query');
    	
    	// loop over filters
    	foreach( $GLOBALS['filtru_culturi'] as $key => $name ) {
    		
    		// continue if not found in url
    		if( empty($_GET[ $name ]) ) {			
    			continue;
    		}
    		// get the value for this filter
    		// eg: https://www.website.com/events?city=melbourne,sydney
    		$values = explode(',', $_GET[ $name ]);
    		foreach( $values as $value ) {
    			$meta_query[] = array(
    				'key' => $name,
    				'value' => $value,
    				'compare' => 'LIKE',
    			);
    		}
            
    	} 
    	// update meta query
    	$query->set('meta_query', $meta_query);
    
    }

    You could use is_sitemap() available in XML Sitemap Feeds to bail this filter:

    
    // bail early
    if( function_exists('is_sitemap') && is_sitemap() ) return;
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘No post included in sitemap’ is closed to new replies.