Forums

Depth parameter not working in wp_dropdown_categories (2 posts)

  1. HotpinkCanadianunicornLOL
    Member
    Posted 3 months ago #

    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:
    http://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?

  2. HotpinkCanadianunicornLOL
    Member
    Posted 3 months ago #

    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>

Reply

You must log in to post.

About this Topic