Forums

wp_dropdown_categories doesn't work in sidebar on Posts, Categories, Archives? (3 posts)

  1. Dgold
    Member
    Posted 2 years ago #

    This code for wp_dropdown_categories does not work properly in my sidebar. What am I doing wrong, or is this template tag crazy?

    <form action="" method="get">
       <?php wp_dropdown_categories('show_option_all&show_count=1&selected=3'); ?>
    <input type="submit" name="submit" value="Go" />
       </form>

    It only works when I'm on the home-page. The problem is on a Post or Archive or Category page, if I use the Dropdown to navigate to another category, it goes to the wrong URI. It just appends ?cat=4&submit=Go to the end of the permalink.

    For example,
    http://mysite.com/wordpress/category/post-name/?cat=4&submit=Go

    That doesn't send you to Category 4, it just sends you back to the Post.

  2. jeremyclark13
    Moderator
    Posted 2 years ago #

    Use this instead.

    <form action="<?php bloginfo('url'); ?>" method="get">
    <?php wp_dropdown_categories('show_option_all&show_count=1&selected=3'); ?>
    <input type="submit" name="submit" value="Go" />
       </form>
  3. Dgold
    Member
    Posted 2 years ago #

    Many thanks! That works.

    Is there any way I can get it to redirect to the pretty permalink for the Category, instead of the
    ?cat=3&submit=Go
    ?

Topic Closed

This topic has been closed to new replies.

About this Topic