Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Customized Category Dropdown menu

Discussion in 'Misc WordPress Requests' started by bcworkz, Nov 2, 2017.

  1. bcworkz

    Guest

    Reply To: Customized Category Dropdown menu, by bcworkz

    That’s fine, just making sure. (the list can be added anywhere on a template by calling the wp_dropdown_categories() function, but requires a different way to exclude categories) You’ll need to compile a list of term IDs you want to exclude and use that in place of the ID numbers in my example. You can get them from the category list table screen. The edit link seen on hover over each term includes a tag_ID URL parameter. The number following this is the ID for that term. Compile into a comma separated list on a single line.

    It appears you are using a child theme, so its functions.php file is a good place for this code, just add it to the end of the file. This code will negate any other exclusion arguments added by other code. If that happens, there’s a fix, but the code gets more complicated, so I’d just as soon avoid it if it’s not needed. Also, if any code is adding an “include” argument, this will cause our added exclusions to be ignored.

    Without further ado, here’s the code to add and in which to edit IDs:

    add_filter('widget_categories_dropdown_args', 'shd_exclude_cats');
    function shd_exclude_cats( $cat_args ) {
    // term IDs to exclude go in the following array, comma separated
    $cat_args['exclude'] = array( 123, 124, 125,);
    return $cat_args;
    }

    Reply To: Customized Category Dropdown menu
     
    #1

Share This Page

Web Hosting