• Resolved JakeThePeg

    (@jakethepeg)


    Howdy. I have a category search on the Home page of my site shackn.com. It uses the following code:

    In relation to the way I write posts and assign categories, my technique is as follows:

    *Every post is assigned a location from the children of “Location” category.
    *Every post is ALSO assigned to EITHER the “Accommodation” or “Surfbreaks” category.

    I would like the results of this search, to only display posts from only the “Surfbreaks” category, but not the “Accommodation” category as well.

    How do I do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • assuming surfbreaks is category id 7, then

    query_posts(array('category__in' => array(7)));

    See the template tag, query_posts()

    Thread Starter JakeThePeg

    (@jakethepeg)

    Thanks Michael….one more question now! How do I display the output of this code in a hierarchical list box (please note, I’d much prefer a list box, with a little scrollbar, rather than a dropdown box, if possible), with a submit button.

    Thread Starter JakeThePeg

    (@jakethepeg)

    Sorry, I’m still not clear on how I can incorporate the query_posts query with the following code:

    <form action="<?php bloginfo('url'); ?>" method="get">
     <?php wp_dropdown_categories('hierarchical=1'); ?>
     <input type="submit" name="submit" value="view" />
     </form>

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Return result from one category only using category search code’ is closed to new replies.