admin管理员组

文章数量:1289529

I have a website with a search in header (anunciaya.es) . I want to order the wp_dropdown_categories by NAME ASC/DESC but it does not work for me.

'orderby' => 'name', and 'order' => 'DESC', is not working for me. Any solution?

Here is the PHP code:

wp_dropdown_categories( array(
    'show_option_none'  => $cat_text,
    'option_none_value' => '',
    'taxonomy'          => rtcl()->category,
    'name'              => 'rtcl_category',
    'id'                => 'rtcl-category-search-' . wp_rand(),
    'class'             => 'form-control rtcl-category-search',
    'selected'          => get_query_var( 'rtcl_category' ),
    'hierarchical'      => true,
    'value_field'       => 'slug',
    'depth'             => Functions::get_category_depth_limit(),
    'show_count'        => false,
    'hide_empty'        => false,
   
) );

Thank you!!

I have a website with a search in header (anunciaya.es) . I want to order the wp_dropdown_categories by NAME ASC/DESC but it does not work for me.

'orderby' => 'name', and 'order' => 'DESC', is not working for me. Any solution?

Here is the PHP code:

wp_dropdown_categories( array(
    'show_option_none'  => $cat_text,
    'option_none_value' => '',
    'taxonomy'          => rtcl()->category,
    'name'              => 'rtcl_category',
    'id'                => 'rtcl-category-search-' . wp_rand(),
    'class'             => 'form-control rtcl-category-search',
    'selected'          => get_query_var( 'rtcl_category' ),
    'hierarchical'      => true,
    'value_field'       => 'slug',
    'depth'             => Functions::get_category_depth_limit(),
    'show_count'        => false,
    'hide_empty'        => false,
   
) );

Thank you!!

Share Improve this question edited Jul 28, 2021 at 14:20 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jul 28, 2021 at 13:41 woofreelancewoofreelance 1
Add a comment  | 

1 Answer 1

Reset to default 0

Hopefully your syntax was correct when you placed order and orderby. In thoery, your code should work with the following

wp_dropdown_categories( array(
    'show_option_none'  => $cat_text,
    'option_none_value' => '',
    'taxonomy'          => rtcl()->category,
    'name'              => 'rtcl_category',
    'id'                => 'rtcl-category-search-' . wp_rand(),
    'class'             => 'form-control rtcl-category-search',
    'selected'          => get_query_var( 'rtcl_category' ),
    'hierarchical'      => true,
    'value_field'       => 'slug',
    'depth'             => Functions::get_category_depth_limit(),
    'show_count'        => false,
    'hide_empty'        => false,
    'orderby'           => 'name',
    'order'             => 'DESC'
   
) );

本文标签: categoriesOrder wpdropdowncategories by ASC or DESC