• agressli

    (@agressli)


    Hi! I was wondering if it is possible to exclude pages from search results if they have specific meta data..?

    This works with wp_list_pages:

    exclude_args=array(
    	'post_type' => 'page',
    	'meta_key' => 'hide_page',
    	'meta_compare' => '=',
    	'meta_value' => 'Yes'
    );
    $pages = get_posts($exclude_args);
    if ($pages) {
    	$pageids = array();
    	foreach ($pages as $page) {
    		$pageids[]= $page->ID;
    	}
    	$args['exclude'] = implode(",", $pageids);
    }

    Thanks in advance!

    https://www.ads-software.com/extend/plugins/search-everything/

  • The topic ‘Exclude pages with meta’ is closed to new replies.