AnswerBun.com

How to sort custom post's category by id from the theme's function, without using a plugin?

WordPress Development Asked by anandmongol on August 10, 2020

I’m wondering how to sort a custom post’s categories in the selection field which I’ve circled in the screenshot?

my idea is to sort custom post's categories in the selection field which encircled

And I have the following code which generates category listing

 $args=array(
                'class'       => 'select-submit2',
                'hide_empty'  => false,
                'selected'    => $prop_category_selected,
                'name'        => 'prop_category',
                'id'          => 'prop_category_submit',
                'orderby'     => 'NAME',
                'order'       => 'ASC',
                'show_option_none'   => __('None','wpestate'),
                'taxonomy'    => 'property_category',
                'hierarchical'=> true
            );
        wp_dropdown_categories( $args ); ?>

One Answer

You need to change the orderby to ID:

            $args=array(
                'class'       => 'select-submit2',
                'hide_empty'  => false,
                'selected'    => $prop_category_selected,
                'name'        => 'prop_category',
                'id'          => 'prop_category_submit',
                'orderby'     => 'ID', //this changed to ID
                'order'       => 'ASC',
                'show_option_none'   => __('None','wpestate'),
                'taxonomy'    => 'property_category',
                'hierarchical'=> true
            );
        wp_dropdown_categories( $args ); ?>

Answered by David Lee on August 10, 2020

Add your own answers!

Related Questions

Style WooCommerce Product Search Widget

0  Asked on December 19, 2020 by chirlet-deusa

     

Role – edit page but not publish

1  Asked on December 15, 2020 by miri-ull

   

How to create a breadcrumb for pages?

3  Asked on December 13, 2020 by msrajjc2

 

Weird issue with is_pages() with array

0  Asked on December 11, 2020 by birdseyedesign

 

WP_Query will not display draft posts

4  Asked on December 11, 2020 by ben-racicot

   

Flickity slider on WordPress: Modify behaviour

1  Asked on December 11, 2020 by vicdilu

 

Add the same content to multiple pages

1  Asked on December 10, 2020

   

Understanding WordPress(framework?) Web Development

2  Asked on December 10, 2020 by anuj-kaithwas

 

How to use value from modal tinymce windowManager?

1  Asked on December 10, 2020 by patrick-paul

   

wp_editor() renders outside wrapping div

0  Asked on December 9, 2020

 

WP REST API: Order posts by meta value (acf)?

2  Asked on December 9, 2020 by mauro-bringolf

       

How to incluide custom field in WooCommerce email using placeholder

0  Asked on December 8, 2020 by santiago-cuartas-rmrz

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir