• Resolved David Jay

    (@david-jay)


    I am using the code provided by @msaari at
    http://wordpress.org/support/topic/terms-of-custom-taxonomy-in-a-dropdown-menu
    to create a dropdown of taxonomy terms and it works great.

    But I am trying to include additional dropdowns, within the same php widget, for different taxonomies and i get the following error:

    Fatal error: Cannot redeclare get_terms_dropdown() (previously declared

    I am only trying to search on one taxonomy at a time. Seems like it should be possible to use dropdowns for more than on taxonomy. Any ideas?

    The code I used is below:

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter David Jay

    (@david-jay)

    My apologies for the rules violation. The deleted code from above is at http://pastebin.com/wpPbPGEQ

    it seems that you are trying to declare the same function name a second time.

    try to remove this section from your code:

    <?php
    function get_terms_dropdown($taxonomies, $args){
    ...
    ...
    return $output;
    }
    ?>

    Thread Starter David Jay

    (@david-jay)

    Actually, the entire code I used in the PasteBin works perfectly. For one taxonomy.

    The problem is when I try to add another dropdown (using the same code) for a different taxonomy. I am not trying to search based on multiple taxonomies, just offer readers the ability to search different ways – one of a few taxonomies.

    adapted version of my earlier reply:

    try to remove this section from the code, when you add it the second time.

    Thread Starter David Jay

    (@david-jay)

    @alchymyth – Thanks so much. That worked.

    I have a follow up question if you don’t mind.

    Do you know how to show starting default text in the dropdown box (e.g., Select a location)? I am familiar with the show_option_none=YOUR DEFAULT TEXT HERE command used with wp_dropdown_categories but can’t get it work with get_terms_dropdown.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cannot redeclare error using get_terms_dropdown’ is closed to new replies.