0

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!!

1 Answer 1

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'
   
) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.