Planty
Planty

Reputation: 83

Creating select from wordpress dropdown

I am using the function below to output categories onto a form with some other inputs.

  <?php wp_dropdown_categories();?>

How am I able to use the option selected from this dropdown and give it a name so that it can be posted along with the other form items?

Upvotes: 0

Views: 49

Answers (1)

Shashikant Chauhan
Shashikant Chauhan

Reputation: 444

<?php wp_dropdown_categories( $args ); ?> 
<?php $args = array(
    'show_option_all'    => '',
    'show_option_none'   => '',
    'option_none_value'  => '-1',
    'orderby'            => 'ID', 
    'order'              => 'ASC',
    'show_count'         => 0,
    'hide_empty'         => 1, 
    'child_of'           => 0,
    'exclude'            => '',
    'echo'               => 1,
    'selected'           => 0,
    'hierarchical'       => 0, 
    'name'               => 'cat',
    'id'                 => '',
    'class'              => 'postform',
    'depth'              => 0,
    'tab_index'          => 0,
    'taxonomy'           => 'category',
    'hide_if_empty'      => false,
    'value_field'        => 'term_id',  
); ?>

In Arguments there is name field so you can use it for form.

Upvotes: 1

Related Questions