Follow @BPSPro

WordPress – Change Category Widget Dropdown List Select Name

11 Comments RSS Site Feed Author: AITpro Admin
Published: May 22, 2010
Updated: May 22, 2010

To change the category widget dropdown list select name in WordPress you will need to modify the /wp-includes/default-widgets.php WordPress file.  The default select name or option value name for the category dropdown widget is “Select Category”.

The line of code you are looking for in the default-widgets.php file is code line 440 in WordPress 2.9.1 and WordPress 2.9.2.  I’m not sure if that code line is different for previous versions of WordPress, but the default-widgets.php file is the file you will need to modify in any case.

Here is what the code looks like at line 44o in default-widgets.php:

/wp-includes/default-widgets.php – Code Line 440

This example is showing that “Select Category” has been changed to “Select Products and Services”.

if ( $d ) {

$cat_args[‘show_option_none’] = __(‘Select Products and Services’);

wp_dropdown_categories(apply_filters(‘widget_categories_dropdown_args’, $cat_args));

Download the default-widgets.php WordPress file, change the category dropdown select name to whatever you want and upload it back to the /wp-includes WordPress folder.

On a personal note I searched high and low for this answer and did not find it out there so hopefully this will be easily found by anyone who wants to modify their category dropdown widget select name.

To change the CSS style for the category widget dropdown list you would add whatever CSS code you want in your WordPress theme’s style.css file.  The CSS class name for the category dropdown list is “postform”.  You may or may not see this CSS class on your particular WordPress theme style.css file so you may need to add it.

This example shows the .postform CSS class with a background color and set to a width of 240px:

.postform {background-color: #CCCCCC; width:240px;}


Tags:

Categories: Wordpress Tips - Tricks - Fixes

11 Comments to “WordPress – Change Category Widget Dropdown List Select Name”


  1. Is there any way of putting it in child theme to avoid update overwrite?

  2. Thanks, I was looking for the file in theme folder, the only problem here is that it will be overwritten in each wordpress update

  3. Reggie Gloss says:

    *** link was removed – not pointing to a valid domain ***

    This is the fitting blog for anybody who desires to find out about this topic. You understand so much its virtually onerous to argue with you (not that I really would need?HaHa). You definitely put a brand new spin on a subject thats been written about for years. Nice stuff, just great!

  4. stephen says:

    hi thanks so much for this – been hunting for this fix all afternoon.

    Stephen

  5. Ramin says:

    Thanks, I was looking for a way to do this.

  6. Jim says:

    And what happens when you update WP?

    • AITpro Admin says:

      Well unfortunately you would have to make the same edit again when you upgrade WordPress. There is probably a better way to hook into this function and control it from your WordPress Theme. I actually need to figure this one out for one of my clients so when I do have a better solution then I will post it here.

      Whoops disregard the info directly below. I didn’t see that this question was for a post unrelated to BulletProof Security. 😉

      Do you mean WordPress Permalinks? If you update the WordPress Custom Permalink Structure then WordPress will write to whatever .htaccess file is in your root folder, which is an info update that I have been meaning to add to the BPS Guide for a while now. I needed to create a post about Custom WordPress Permalinks themselves before including this in the guide. That post has just been created last night so now I will update the Guide. Updating the WordPress App itself is not a factor at all. BPS is just like any other plugin when it comes to updating the WordPress core app – you would just deactivate the BPS plugin like all of your other plugins and perform the WordPress upgrade / update. Thanks.
      Ed

      *** Update ***
      I have not tried this code yet, but logically it would be something like this. You would add this to your Theme functions file. When i have a minute i will test this out and correct anything that needs to be corrected, but if you want to tinker this is the direction you would go in.

      $new_select_name = "Select Products and Services"
      function dropdown_cat_select_name( $new_select_name ) {     
      if ( $d ) {
      return str_replace(array('[[', ']]'), array('<', '>'), $new_select_name); 
      } 
      }
      add_filter('widget_title', 'dropdown_cat_select_name', 11); // 11 is one above the default priority of 10, meaning it will occur after any other default widget_title filters 
      
  7. zwerater says:

    ” The default select name or option value name for the category dropdown widget is “Select Category”.”
    How much is it possible?

  8. Mihai says:

    Thanks a lot! It helped me out!


Skip to toolbar