New answers tagged

0

The Code from ialocin works pretty well, but there is a mistake in the last part. It is supposed to be like this: Part 1: <form method="POST" action=""> <div> <?php $args = array( // hierarchical is needed to define depth 'hierarchical' => 1, // regions are the top ...


0

Using the wp_dropdown_categories() function there's a parameter you can use called selected which you would assign the selected category ID. You should also standardize the name of your select so it's easier to save: $selected_id = get_post_meta( $post->ID, 'selected_tax', true ); wp_dropdown_categories( array( 'show_option_all' => 'Choose a ...


1

You can try using Chosen. I use it because it's bundled with WooCommerce. It basically adds search box to the <select> element. I leave the styling to you. The easiest solution is to add it as a plugin. But you can add it to your theme if you want. Add the CSS and JS files: <?php function custom_scripts_wpse_215576() { //Chosen CSS file ...


0

You should be able to do a similar thing as described in that answer and filter the output from wp_category_dropdown using wp_dropdown_cats, but for the options instead of select eg. add_filter('wp_dropdown_cats', 'wp_dropdown_categories_multiselect'); function wp_dropdown_categories_multiselect($output) { $valuekey = 'valuekey'; // set to 'name' ...


0

Thanks @markkaplun. I solved it writing my own: <?php /** * Dropdown for 'my_tax' * @since 1.0.0 Using wp_dropdown_categories(). * @since 2.0.3 Custom code, as wp_dropdown_categories() doesn't provide * 'selected' field for multiple="multiple" */ $my_tax_terms = get_terms( 'my_tax', array('hide_empty'=>false) ); echo '<select ...


1

As the core tickets (for example https://core.trac.wordpress.org/ticket/16734) say the point of the api is to provide a dropdown and not a multiselect. IIRC in the quick edit of posts no API is being used for the category and tags multiselct. In other words, just ignore the API and write your own.



Top 50 recent answers are included