WordPress.org

Plugin Directory

Intuitive Custom Post Order

Intuitively, Order Items (Posts, Pages, and Custom Post Types, and Custom Taxonomies) using a Drag and Drop Sortable JavaScript.

How to re-override the parameters of 'orderby' and 'order'

Sub query

Use the 'WP_Query', you can re-override the parameters.

<?php $query = new WP_Query( array(
    'orderby' => 'date',
    'order' => 'DESC',
) ) ?>

Main query

Use the 'pre_get_posts' action hook or 'query_posts', you can re-override the parameters.

pre_get_posts

function my_filter( $query )
{
    if ( is_admin() || !$query->is_main_query() ) return;
    if ( is_home() ) {
        $query->set( 'orderby', 'date' );
        $query->set( 'order', 'DESC' );
        return;
    }
}
add_action( 'pre_get_posts', 'my_filter' );

query_posts

<?php query_posts( array(
    'orderby' => 'rand'
) ); ?>

Requires: 3.5.0 or higher
Compatible up to: 4.1.0
Last Updated: 2015-2-10
Active Installs: 80,000+

Ratings

4.4 out of 5 stars

Support

2 of 12 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

2 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1 0,1,0
0,1,0 75,8,6 75,4,3
100,2,2 100,1,1 100,1,1
100,3,3
100,2,2
100,2,2
0,1,0 50,2,1
0,2,0 67,3,2
50,2,1
100,3,3
100,4,4
50,2,1
100,1,1 100,1,1 100,1,1
100,2,2