Skip to main content
13 votes

Removing filter dropdown in posts table (in this case Yoast SEO)

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', '...
BenB's user avatar
  • 795
7 votes
Accepted

Add a dropdown to theme customizer

Add Section to Theme Customizer: $wp_customize->add_section( 'parsmizban_options', array( 'title' => __( 'Theme Options', 'parsmizban' ), //Visible title of section 'priority' ...
Farhad Sakhaei's user avatar
5 votes

How to add html attributes to the "ul" html tag with "wp_nav_menu" function?

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' ...
Stephan's user avatar
  • 51
4 votes

How to use an array of categories as a dropdown?

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('...
laviku's user avatar
  • 143
4 votes

How to add HTML5 'required' attribute to wp_dropdown_categories() without JavaScripts?

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-...
Mayeenul Islam's user avatar
4 votes

Remove “Choose An Option” on Product Variation & Auto Select Instead

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($...
Aparna_29's user avatar
  • 339
4 votes
Accepted

Block Editor: add an aria-label to an option inside a SelectControl

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 ...
Sally CJ's user avatar
  • 39.3k
4 votes
Accepted

wp_dropdown_categories and custom taxonomy + custom post type

You can get your code to work the expected way by adding the following three arguments to your $args array which you pass to wp_dropdown_categories(): name — the select name as in <select name=&...
Sally CJ's user avatar
  • 39.3k
4 votes

How to force the Author Dropdown to display in Quick/Bulk edit?

After digging through many bug reports I found a solution to the issue I was facing. The problem I was having is related to a new feature in 6.0 for sites with over 10K user accounts which ...
user3593214's user avatar
3 votes

How do I give class to the dropdown sub-menu in the wp_nav_menu?

You can use Walker_Nav_Menu (WordPress Default class). Here is an example - In header.php file - <nav id="header-menu"> <?php wp_nav_menu( array( 'theme_location' => 'primary', ...
Chirag Patel's user avatar
3 votes

Display custom taxonomy as dropdown list

Below is the easiest solution I use for displaying custom taxonomy as the dropdown instead of checkboxes. 1/ Use third party WordPress plugin 'ACF' to create the taxonomy 'Relational' field type and ...
dhirenpatel22's user avatar
2 votes

How do I display only two categories Instead of displaying all categories

This can be done easily using include parameter. Check the documentation of wp_dropdown_categories(). You can pass category id's to include parameter as a array. <?php wp_dropdown_categories( '...
Ranuka's user avatar
  • 1,794
2 votes

Add submenu using the bootstrap wp_nav_menu

You will need to write a custom menu walker. See this code for the walker. (Or do a search for "Bootstrap Menu Walker".) Then use: wp_nav_menu( array( 'menu' => 'header', '...
Vino's user avatar
  • 151
2 votes

Removing filter dropdown in posts table (in this case Yoast SEO)

and you can add this line to the above function to remove the readability dropdown too: remove_action( 'restrict_manage_posts', array( $wpseo_meta_columns, 'posts_filter_dropdown_readability' ) )...
medicamin's user avatar
2 votes

wp_dropdown_categories in custom post type with custom taxonomy

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=$...
RafaSashi's user avatar
  • 477
2 votes
Accepted

How do I use Ajax to build a dropdown of custom fields based on a post selected in previous dropdown?

In dynamic_dropdown_func(), at the end try echo $event_dates; instead of return $event_dates;. Also, I'm wondering why you declare global $wpdb; when you don't seem to use it?
scott's user avatar
  • 465
2 votes
Accepted

Select dropdown not showing selected value php

The reason your $item == $option condition is always failing is because of the way PHP compares floats! Try the following instead: echo "<option value='$item'" . selected (abs ($item - $options) &...
Paul 'Sparrow Hawk' Biron's user avatar
2 votes

Dropdown list of pages to get page id to store in plugin options

Iam using following code to display a page select dropdown menu on an plugin option page. If you select an page and save it, the next time you visit the option-site, you will also see which page was ...
LWS-Mo's user avatar
  • 1,522
2 votes
Accepted

Dropdown filter in custom posts

When using this hook, your function receives two parameters, onde of them is the slug of the current post_type; <?php function my_post_type_filter($post_type) { $post_slug = $post_type; ...
Cesar Henrique Damascena's user avatar
2 votes
Accepted

Dropdown menu not displaying Wordpress

This is a CSS issue not related to WordPress maybe to Woocommerce, try adding: .select2-container{ z-index:10000; } the number seems high but i tried different ones thats the one that works.
David Lee's user avatar
  • 3,891
2 votes

Change The Woocommerce Product Categories Dropdown Widget Placeholder Text

This worked for me: add_filter( 'wp_dropdown_cats', function( $html, $args ) { if ( $args['taxonomy'] === 'product_cat' ) { $html = str_replace( '<select', '<select data-placeholder=...
MandyS's user avatar
  • 21
2 votes
Accepted

Filter dropdown in users.php "delete user" bulk edit screen

One way is by using the load-users.php hook which is fired only on the wp-admin/users.php page, and then use the wp_dropdown_users_args filter to modify the parameters (e.g. the role parameter) passed ...
Sally CJ's user avatar
  • 39.3k
2 votes

Use a filter on menu items that have children

There is indeed a filter, walker_nav_menu_start_el will be able to handle it for you! Take this code for example: function wpse356896_filter_primary_nav_menu_dropdown( $item_output, $item, $depth, $...
Tim Elsass's user avatar
  • 1,343
2 votes
Accepted

Modify output of wp_dropdown_categories to add term IDs to each option

get_terms ended up bring a more customizable solution which is working for my needs. I was able to easily add the term IDs to each option as needed. Hope this helps someone else. <div class="...
Greg's user avatar
  • 31
1 vote

How to create dependent dropdown custom field in wordpress admin post form

If the form is in post edit, I'll probably enqueue a script for my dropdown on edit page, and I'll use metabox to add a form un WordPress post edit. Metabox Documentation on WP Codex
Elex's user avatar
  • 1,045
1 vote

How to make drop down post title

It's better to use the wp_ajax_ action in an init action. In fact, wp_ajax_ action need to be accessable from anywhere. Use of the init action hook could make it work like it does. Hope it works
Benoti's user avatar
  • 2,436
1 vote

Wordpress Customizer: Dropdown with Category output

I have a solution to this First create section // FRONT Page Settings settings. $wp_customize->add_section( 'betacoders_theme_front_page_options', array( 'title' => __('📝 - ...
Mohammad Ayoub Khan's user avatar
1 vote

Dropdown list of pages to get page id to store in plugin options

Try below code. <select name="page"> <option value=""><?php echo esc_attr( __( 'Select page' ) ); ?></option> <?php $pages = get_pages(); foreach ( $...
AddWeb Solution Pvt Ltd's user avatar
1 vote

Wordpress custom dropdown listings

Populate your data something like this and and you can use Javascript/jQuery to achieve this. <select class='apple_store_location'> <option value='1' data-url="http://mysiteurl.com/1"> ...
Third Essential Designer's user avatar
1 vote
Accepted

why is this function firing on all child menu items as well?

The $args parameter are the arguments of the entire menu not of the single menu item, you can see it here in the file itself that uses and executes the filter: @param stdClass $args An object of ...
David Lee's user avatar
  • 3,891

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