• hotpinkcanadianunicornlol

    (@hotpinkcanadianunicornlol)


    I’m pretty new to editing php parameters, but I’m trying to get wp_dropdown_categories to work with my search form. All I need it to do is exclude a few categories, and also only display top-level categories. The exclude parameter is working but depth isn’t. Can anyone help me troubleshoot? Here’s my searchform code:
    <form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”>
    <label class=”hidden” for=”s”><?php _e(‘Search for:’); ?></label>
    <div><input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” />
    <?php wp_dropdown_categories(‘exclude=1,42,147,174&depth=1’); ?>
    <input type=”submit” id=”searchsubmit” value=”Search” />
    </div>
    </form>

    And here’s my search page:
    https://ronsdalepress.com/search

    The only categories that should be appearing are ‘All Books’ and ‘Authors’, as they’re the only non-excluded top-level categories. Instead, all the non-excluded categories, including child categories, are displaying. Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter hotpinkcanadianunicornlol

    (@hotpinkcanadianunicornlol)

    Edited to include code that actually works–still having the same problem, ‘depth’ does nothing…
    <form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”>
    <label class=”hidden” for=”s”><?php _e(‘Search for:’); ?></label>
    <div><input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” />
    <?php wp_dropdown_categories(‘depth=1&hierarchal=true&exclude=1,42,147,174&hide_empty=1&show_option_all=Entire Site’); ?>
    <input type=”submit” id=”searchsubmit” value=”Search” />
    </div>
    </form>

    I think you can use exclude_tree instead of exclude. This way, you won’t have to the depth parameter neither..

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Depth parameter not working in wp_dropdown_categories’ is closed to new replies.