I've spent a day or so on this now and I'm turning to the community for assistance.
Firstly, I am trying to achieve something like this post:
Wordpress Multiple Category Search
In my theme template, I have a custom search form:
<form id="searchform" method="get" action="<?php bloginfo('url'); ?>">
<fieldset>
<input type="text" name="s" value="" placeholder="Search..."></input>
<button type="submit">Search</button>
<div class="clear"></div>
<div class="search_category_section">
<?php
$args = array('parent' => 0);
$categories = get_categories($args);
echo '<div class="search_category_section">';
foreach ($categories as $category) {
$thecatid = $category->cat_ID;
echo '<div class="categorylist"><div class="parent_category_list_item"><input id="', $thecatid, '" type="checkbox" name="category_name" value="', $category->slug, '"><label for="', $thecatid, '">', $category->name, '</label></input></div>';
$childcats=get_categories(array('parent' => $thecatid));
foreach($childcats as $c) {
echo '<div class="child_category_list_item"><input id="', $c->cat_ID, '" type="checkbox" name="category_name" value="', $c->slug, '"><label for="', $c->cat_ID, '">', $c->name, '</label></input></div>';
}
echo '</div>';
}
?>
</div>
</fieldset>
So, let's say for example I search for "keyword", and I select two checkboxes, "category A" and "category B". I have two posts, one in each category. Each of those two posts has that keyword in it. After hitting the submit button it generates the following URL:
mydomain.com/?s=keyword&category_name=category-a&category_name=category-b
What this is currently doing is presenting me with one result - that is, one post from category B with that keyword in it.
What I'm actually looking for is this result:
mydomain.com/?s=keyword&category_name=category-a,category-b
Whereby I get all posts in all categories, with that keyword in it.
I've looked high and low, and while I've found results where others were trying to achieve a similar thing, none of their solutions worked for me.
This is all part of a learning curve for me. I have found this plugin which looks like it will do what I want, but as you've all probably been in this situation whereby "I wish I could do this myself so that I understand better how the mechanics behind Wordpress" work I hope you'll appreciate the question.
Thanks in advance, if anything isn't clear or I've left vital info out let me know.