K
K
ksshk2018-04-02 16:37:56
WordPress
ksshk, 2018-04-02 16:37:56

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>

It displays all the categories in the select, and below all the tags in the form of checkboxes.
It is necessary to make sure that when you select a specific rubric, those tags that are in the selected rubric become active. The rest were not active.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
E, 2018-04-02
@aylo

учебник по javascript решит проблему.

Вы просто задаете вопрос и думаете что вам тут напишут готовый код, который стоит денег.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question