Forums

remove results from search results based on custom meta value (4 posts)

  1. Matthew Burrows
    Member
    Posted 11 months ago #

    Hello all,

    I want to remove results from search.php based on a posts meta value.

    I have set up a "new WP_Query" but on the results page it just lists all the posts in the database.

    This is the code I am currently using - http://www.pastie.org/2106317

    Any help is much appreciated.

    Matt.

  2. knightrojen
    Member
    Posted 11 months ago #

    A quick test on my local copy shows nothing with a custom parameter (as expected) - do all posts have that parameter?

  3. knightrojen
    Member
    Posted 11 months ago #

    And some additional details and some code to help reach a solution:

    http://groups.google.com/group/wp-hackers/browse_thread/thread/26aa4b9d4fbdd7e9?pli=1

  4. knightrojen
    Member
    Posted 11 months ago #

    Sorry, save yourself from clicking, but what I ended up using based off the google group posting:

    // query for a given term ("search_term") in some given categories (7 and 8)
    $search_query = new WP_Query();
    $search_posts = $search_query->query('s=search_term&cat=7,8');
    // build loop
    foreach($search_posts as $search_post) {
            setup_postdata($search_post);
            // do stuff
    }

Reply

You must log in to post.

About this Topic