I have an issue with the search results after I have created a customized searchform.
What I want to achieve is the following:
In the search from there are 2 fields for dropdown categories.
The first field are the 2 children of the head category.
The second field are the children of the children.
My search form is like this:
<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>"> <input type="text" value="" name="s" id="s" /> in <?php wp_dropdown_categories( 'show_option_all=land&child_of=70&hierarchical=1&depth=1' ); ?> <?php wp_dropdown_categories( 'show_option_all=Provincieën&child_of=71&hierarchical=1&depth=1' ); ?> <input name="site_section" type="hidden" value="bedrijvengids" /> <input type="submit" id="bedrijvengids" value="Zoek" /> </form>
My search results should exclude all other categories so should only search in the main category (in the above code that’s category 70), ignoring all other main categories.
My issue is that when I do nothing with the search results page it shows results from all categories.
When I use a wp_query(); to only take posts from the maincategory… I get all posts in the child categories instead of posts from the chosen categories in the dropdowns. My code for the search results is:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("s=$s&paged=$paged&cat=70");?> <?php if(have_posts()) : ?> <?php while(have_posts()) : the_post() ?> <?php the_content();?> <?php endwhile; ?>
What is going wrong? am I forgetting something? All help is welcome! Thanks so much in advance.
- The topic ‘Search results issue’ is closed to new replies.