Sample code on how to apply the sort for Post Types Order plugin

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

The Post Types Order plugin is a great tool for sorting site content. It include the Autosort functionality, if turned on will auto-apply the customized order to all queries, there’s no need to modify any code. This makes it the ideal tool for people who don’t care about programming and just want an out-of-the-box tool.

Sort can also apply only to certain queries, the Autosort need to be turned OFF. The ‘orderby’ => ‘menu_order’ need to be included within custom query arguments.

$args = array(
              'post_type' => 'feature',
              'orderby'   => 'menu_order',
              'order'     => 'ASC'
            );
$my_query = new WP_Query($args);
while ($my_query->have_posts())
    {
        $my_query->the_post();
        (..your code..)          
    }

The sort can be reversed using the ‘order’ => ‘DESC

$args = array(
              'post_type' => 'feature',
              'orderby'   => 'menu_order',
              'order'     => 'DESC'
            );

When using Autosort, there is a filter pto/posts_orderby/ignore to ignore specific queries, more details at Ignore sort apply for certain query on Post Types Order

For advanced queries and sorts see the Advanced Post Types Order and it’s Documentation.