Tag Info

New answers tagged

0

You will need an opening select tag that tells PHP it is an array. Something along the lines of the following should get you on your way... <?php // Display Fields add_action( 'show_user_profile', 'add_multiple_choice_dropdown ' ); add_action( 'edit_user_profile', 'add_multiple_choice_dropdown ' ); function add_multiple_choice_dropdown ( $user ) { ...


1

If you want to apply the required attribute every time you use wp_categories_dropdown, use wp_dropdown_cats filter as suggested in other answers: add_filter( 'wp_dropdown_cats', 'wp_dropdown_categories_required' ); function wp_dropdown_categories_required( $output ){ return preg_replace( '^' . preg_quote( '<select ' ) . '^', ...


1

If you have a look into the function in wp-includes/category-template.php you will see, there is no option for 'required' build in. So we have to choose another way since $args['required'] doesn't work - as you know. We find the filter 'wp_dropdown_cats', which provides us with the output just before the function returns this output. So we could work with ...


1

There's a filter - wp_dropdown_cats (not documented anywhere as far as I know.) It gives you two parameters, the HTML string and an array of the arguments supplied to wp_dropdown_categories, and you need to return the new HTML.



Top 50 recent answers are included