WordPress.org

Ready to get started?Download WordPress

Forums

Search Everything
Exclude pages with meta (1 post)

  1. agressli
    Member
    Posted 1 year ago #

    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!

    http://wordpress.org/extend/plugins/search-everything/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic