Search code examples
wordpresscategoriescustom-post-type

Wordpress get post order by custom category


I am getting custom post. How can i order them by custom category. My custom category name is 'weeks'. These are my args.

$args = array(
                        'post_type' => $post_type,
                        'post_status' => 'publish',
                        'caller_get_posts' => 1,
                        'orderby' => 'title',
                        'order' => 'ASC',
                    );

I use orderby 'title'. But it did not work.


Solution

  •     $args = array(
                        'post_type' => $post_type,
                        'post_status' => 'publish',
                        //'caller_get_posts' => 1, // use this option to ignore sticky posts, else you don't need to include this parameter
                        'tax_query' => array(
                            array(
                                'taxonomy' => 'weeks',
                                ),
                        ),
                        'orderby' => 'post_title',
                        'order' => 'ASC',
                    );