Support » Plugins » Hacks » select list of categorys with the option multiple

  • Resolved paka



    I want to display a select form with the posibility to select multiple categorys.
    With wp_dropdown_categories you can only select one.
    Is there any WP function, to do this, or have I to do it per querry to the table wp_terms. If this is so, how can I tell there categories from tags.


    PS. I hope, it’s possible, to understand my question, but I’m not acustomed to write in english.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Second problem solved.

    I found the tables, to select the categories,:-) but this was’nt the reason, why I posted this question.
    You find the categories and tell them from tags, with the tables wp_terms and wp_term_taxonomy.

    It would be nice, if there is a solution to the first one, because I would prefer a WP function, and this is, why I asked.


    You could hack the multiple selection on there using str_replace with wp_dropdown_categories, and could probably do something similar for wp_list_categories..

    $select_cats = wp_dropdown_categories( array( 'echo' => 0 ) );
    $select_cats = str_replace( 'id=', 'multiple="multiple" id=', $select_cats );
    echo $select_cats;

    Hello Mark / t31os
    tank you, this was quick.

    It works, the only thing, I had to change from your posted code was, that I had to change the name attribute too, to get an array $_POST[‘cat’] instead of only one value. It has to be name=’cat[]’. But this is only a xhtml detail, the point was, to use str_replace on the return value of wp_dropdown_categories.
    The code I use now is this:

    $select_cats = wp_dropdown_categories( array( 'echo' => 0 ) );
    $select_cats = str_replace( "name='cat' id=", "name='cat[]' multiple='multiple' id=", $select_cats );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘select list of categorys with the option multiple’ is closed to new replies.