9

You can add new taxonomy with your own metabox since wp 3.8 by meta_box_cb "drop_cat()" - consist of rebuild original core category metabox wp-admin/includes/meta-boxes.php function realty_type() { $args = array( 'show_ui' => true, 'meta_box_cb' => 'drop_cat', ); register_taxonomy( 'realty_type', array( '...


9

As answered by Steven Jones in the comments, I just want to confirm that the key thing is to specify your custom post type's settings to be 'hierarchical' => true, not the hierarchical argument in wp_dropdown_pages function. If you are using a custom plugin like Types or CPT UI, just set the option to true.


9

We can get the categories via get_categories() function (which will get the same categories as wp_dropdown_categories() function), but as array and without the markup. As the value is returned as array, we can loop through the categories and generate the HTML ourself. Usually, we would aim for a structure like this: <select name="categories"> <...


8

Updated answer for Yoast SEO Version: 7.0.2 This will remove both seo score filter and readability filter from posts list edit page in WordPress admin. add_action( 'admin_init', 'bb_remove_yoast_seo_admin_filters', 20 ); function bb_remove_yoast_seo_admin_filters() { global $wpseo_meta_columns ; if ( $wpseo_meta_columns ) { remove_action( '...


7

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 ' ) . '^', '<...


6

Try this, $categories_array = array(); $categories = get_categories(); foreach( $categories as $category ){ $categories_array[] = $category->term_id; } array( 'param_name' => 'category_id', 'type' => 'dropdown', 'value' => $categories_array, // here I'm stuck 'heading' => __('Category filter:', 'overmax'), ...


6

Ok I found it, here is the answer for next ones who are looking for the same thing: $cf7forms_list = array(); $args = array('post_type' => 'wpcf7_contact_form'); $cf7forms = get_posts( $args ); foreach($cf7forms as $cf7form) { $cf7forms_list[$cf7form->post_title] = $cf7form->post_title; } $wp_customize->add_setting( 'contact_list_section', ...


5

These additional dropdowns are added via the restrict_manage_posts action hook. This means the dropdown output isn't filterable, but you can remove the hooked action from Yoast SEO. The filter dropdown is added by the posts_filter_dropdown() method in the WPSEO_Metabox class. It's added in the setup_page_analysis() method of the same class, which is hooked ...


5

Add Section to Theme Customizer: $wp_customize->add_section( 'parsmizban_options', array( 'title' => __( 'Theme Options', 'parsmizban' ), //Visible title of section 'priority' => 20, //Determines what order this appears in 'capability' => 'edit_theme_options', //Capability needed to tweak 'description' => __('...


4

You can use the following piece of code. <form action="<?php bloginfo('url'); ?>" method="get"> <?php $select = wp_dropdown_pages( array( 'post_type' => 'ce_artists', 'show_option_none' => 'Select Artist', 'echo' => 0 ...


4

In addtion to the answer, if you want that you dropdown value has the id of the category you should do something like this: $categories_array = array(); $categories = get_terms('tax_id', array('hide_empty' => false)); foreach( $categories as $category ){ $categories_array[$category->name] = $category->term_id; }


4

Here is a variation of the code that you use. I'm using get_categories() here to achieve the same goal. I had to adjust my code slightly to make it acceptable for your need. There are a however other modifications you have to make for this to work. When you select the All Categories option, you will be taken to a page that will display what ever you need to ...


4

You could probably just modify the script above to this: var dropdown = document.getElementById("cat"); function onCatChange() { if ( dropdown.options[dropdown.selectedIndex].value > 0 ) { location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value; } else if ( dropdown.options[...


4

I'm surprised it's all that slow but you can remove all but one of the database calls & most of the looping by passing the term data instead of just slugs to my_dropdown_categories() so get_terms() doesn't have to be called, plus a few other improvements (see comments) eg: function my_dropdown_categories( $taxonomy, $current_selected = '', $terms = ...


4

Update: WordPress 4.6 As from WordPress 4.6 we can add a 'required' attribute directly to wp_dropdown_categories(). <?php $args = array( 'show_option_none' => __( 'Select one', 'text-domain' ), 'taxonomy' => 'my_tax', 'id' => 'tax-type', 'echo' => 1, 'required' => true )...


4

Thank you so much, it's working. Here is my modified code: function wpse45436_posts_filter( $query ){ global $pagenow; $type = 'post'; if (isset($_GET['post_type'])) { $type = $_GET['post_type']; } if ( 'post' == $type && is_admin() && $pagenow =='edit.php' && ...


4

To change <option value='http://someurl'>item one</option> <option value='http://someurl'>item two</option> <option value='http://someurl'>item three</option> to <option value='http://someurl'>1. item one</option> <option value='http://someurl'>2. item two</option> <option value='http://...


4

I agree with Nathan's answer, but you can copy the source and create your own SelectControl component based on that source. Here's an example, with basically just the aria-label addition: <option key={ `${ option.label }-${ option.value }-${ index }` } value={ option.value } disabled={ option.disabled } aria-label={ option.ariaLabel || '' ...


3

selected() was big help for setting a default value. The rest I found in this brilliant meta box tutorial: http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes--wp-20336 with examples for text input, checkboxes and dropdown. Also Custom post type's slug gets wrong when adding a custom meta box explained me how to correctly ...


3

I use wp_dropdown_categories() function, it help keep my code clean. Here is my code. <p> <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Select category', 'textdomain' ); ?>:</label> <?php wp_dropdown_categories( array( 'show_option_none' =>' ','name' => $this->get_field_name( '...


3

You already have <option value="">...</option> you just need some extra attrs for it You need to load current value and if value equals $page->ID than add attr selected="selected" Here's how it could be done: <select name="easyreg_redirect_page"> <option selected="selected" disabled="disabled" value=""><?php echo esc_attr(...


3

You don't need a walker. You can pass 'items_wrap' through wp_nav_menu(): <?php wp_nav_menu( array( 'theme_location' => 'main-menu', 'menu_id' => '', 'items_wrap' => '<ul data-hover="dropdown" data-animations="zoomIn zoomIn zoomIn zoomIn" class="%2$s" id="%1$s">%3$s</ul>', 'container' => ...


3

Following code solves the purpose: add_filter('woocommerce_dropdown_variation_attribute_options_args','fun_select_default_option',10,1); function fun_select_default_option( $args) { if(count($args['options']) > 0) //Check the count of available options in dropdown $args['selected'] = $args['options'][0]; return $args; }


2

get post id $post_id=get_the_ID(); get selected region $terms = wp_get_post_terms( $post_id, $taxonomy ); $selected_id=''; if(isset($terms[0]->term_id)){ $selected_id=$terms[0]->term_id; } build hierarchical dropdown wp_dropdown_categories( array( 'show_option_all' => 'Choose a region', '...


2

I'm not a programmer so there's probably a far more efficient/correct way of doing this. Put this in functions.php or a custom plugin: function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->get_results( "SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt....


2

Like I said in the comment, this can be solved by using two dropdowns. Additionally I already hinted you to an answer of mine doing this for a simple, one level, non conditional category selection. Category dropdowns can easily constructed with wordpress by making use of wp_dropdown_categories. To make it work as actual selection handed over to a query the ...


2

I've been stuggeling with a similar issue. (button not appearing in mce editor toolbar). This pattern worked for me in WP 3.9 / tinymce 4.0: tinymce.PluginManager.add( 'thing' , function( editor ){ editor.addButton('thing', { type: 'listbox', text: 'My listbox', onselect: function(e) { // do things... }, ...


2

We can use depth parameter of wp_nav_menu to set how many levels menu walker traverses. wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' , 'depth' => 1) ); You can create a child theme so that updates won't override during updates. Create child theme and copy code from header.php of parent theme then replace the code ...


2

I was going to add this as a comment, but my rep points aren't high enough yet :) I spent about 20 mins testing/ walking through what you have. My first test replicated the problem you describe, but when I set up some breakpoints (the change event and a specific LOC) and watch expressions using the built in Chrome debugging tools, the problem appears to ...


2

Try this /* Save selected data */ add_action( 'personal_options_update', 'save_user_fields' ); add_action( 'edit_user_profile_update', 'save_user_fields' ); function save_user_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) return false; update_usermeta( $user_id, 'country', $_POST['country'] ); } add_action( '...


Only top voted, non community-wiki answers of a minimum length are eligible