Answer the question
In order to leave comments, you need to log in
How to display tags that belong to a category in advanced search?
It is necessary to make an advanced search by headings and tags.
There is a code:
<form method="get" action="<?php bloginfo('url'); ?>">
<fieldset>
<input type="text" name="s" value="" placeholder="поиск..." maxlength="50" required="required" />
<select name="category_name">
<?php
// генератор списка рубрик
$categories = get_categories();
foreach ($categories as $category) {
echo '<option value="', $category->slug, '">', $category->name, "</option>\n";
}
?>
</select>
<p>Уточните пожалуйста метки для поиска:</p>
<?php
// генератор списка меток
$tags = get_tags();
foreach ($tags as $tag) {
echo
'<label>',
'<input type="checkbox" name="taglist[]" value="', $tag->slug, '" /> ',
$tag->name,
"</label>\n";
}
?>
<button type="submit">Поиск</button>
</fieldset>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question