Sample Usage
The Advanced Post Types Order plugin does all work for you when Autosort setting is turned ON, however in certain situations custom queries are required to be run along with Autosort turned OFF.
Return feature post types objects, using the order set for the archive (all feature post type items):
$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..)
}
Return feature post types objects, using the order set for the ‘movies’ taxonomy within the term called ‘Titanic’ (id 10):
$args = array(
'post_type' => 'feature',
'orderby' => 'menu_order',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'movies',
'field' => 'id',
'terms' => 10
)
)
);
$my_query = new WP_Query($args);
while ($my_query->have_posts())
{
$my_query->the_post();
//(..your code..)
}
There are situations when Autosort is ON and you need to exclude the order from a query to return in random order, in such situations the force_no_custom_order parameter will help
$args = array(
'post_type' => 'feature',
'orderby' => 'rand',
'force_no_custom_order' => TRUE
);
$my_query = new WP_Query($args);
while ($my_query->have_posts())
{
$my_query->the_post();
//(..your code..)
}
In case of using get posts the ‘suppress_filters’ => false need to be included as by default ‘suppress_filters’ is set as true:
$args = array(
'post_type' => 'feature',
'orderby' => 'menu_order',
'order' => 'ASC',
'suppress_filters' => false
);
$my_posts = get_posts($args);
foreach($my_posts as $post)
{
setup_postdata($post);
//(..your code..)
}
FAQ Index-
Mika
-
nspcode
-
-
Alexandre Lino
-
nspcode
-
Alexandre Lino
-
nspcode
-
-
-
-
Andrew Croce
-
nspcode
-
-
mimetic



