WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_dropdown_categories (6 posts)

  1. joshrodgers
    Member
    Posted 2 years ago #

    I am using wp_dropdown_categories (http://codex.wordpress.org/Function_Reference/wp_dropdown_categories) to display a dropdown menu for my site. I have a ton of categories and only need the dropdown for one or two of them. However, as the codex indicates, there is only an exclude feature. I know there has to be some kind of function or something I can use for an "include" option.

    My code looks like:

    http://pastebin.com/atrqWwdD

    Anyone have any ideas?

    Thanks,
    Josh

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    have you tried to use 'include' even if it is not explicitely mentioned in the codex or the core file?

    somewhere down the line, this functions uses 'get_terms()' which supports 'include' ...

  3. joshrodgers
    Member
    Posted 2 years ago #

    alchymyth,

    I just tried it a few minutes ago and it doesn't work :( However, I'm glad you mentioned that, hadn't thought to try it and see :)

    Thanks,
    Josh

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    too bad - seems to work with the default taxonomy 'category':

    wp_dropdown_categories('taxonomy=category&id=make&show_option_all=Select Make...&include=9,1');

    I don't have any cusotm taxonomes set up at the moment to test further.

  5. Digital Raindrops
    Member
    Posted 2 years ago #

    Hi Josh,
    I think you would create your own category dropdown and use get_categories() wich has the 'include' argument.

    I use categories dropdown in this child theme, you can get an example in the download, /inc/pop-meta-functions.php code, line 64 you would need to add the 'include', the dropdown is lines 90-103

    Thinking a little "outside the box" if the theme supports custom menus create a custom menu and add the categories, in code call the menu with wp_get_nav_menu_items() adding these into a select dropdown, much cleaner and loads more control.

    HTH

    David

  6. joshrodgers
    Member
    Posted 2 years ago #

    David,

    That's a great idea, I'll definitely use get_categories instead of wp_dropdown_categories!

    Thanks,
    Josh

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.