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

    If i understand correctly the ‘
    force_no_custom_order’ is still usable along with Autosort is Turned ON, to overwrite a custom order for a theme query ?

    • nspcode

      Yes that is correct. This parameter will allow to control the order as default/custom independently of the Autosort status.

  • Alexandre Lino

    Very nice plugin. However, when the plugin is acftivated, i´m unable to sort my post or page list by title or date by clicking at column name in admin. Sorry if is an old question, couldn´t find any references about this issue. Thanks, nice work!

    • nspcode

      From my knowledge this has never been a problem of Advanced Post Types Order, but an issue with the free Post Types Order which was fixed months ago.
      However if you are using an older version that 2.5.3.6 you should update.

      • Alexandre Lino

        That´s correct, i´m using the free version (1.5.4) Is there a fix for the free version? I´m considering to buy ATO in few days. Thanks for de information.

        • nspcode

          Sorry but this board is only for the Advanced Post Types Order only.
          There should be a fix for that in the next release of the free plugin, unfortunate i don’t have a time-frame for that.

  • Andrew Croce

    It seems this plugin does not work on queries called by the get_posts() function. If I switch over to using a new WP_Query() to get posts, it does. Is it possible to use this plugin with get_posts() or do I need to stick to the other method?

    • nspcode

      In fact it works fine with WordPress template get_posts(), you just need to add ‘suppress_filters’ => FALSE within the arguments as this is set as TRUE by default, meaning certain query filters are not triggered.

      Here is an example:

      $args = array(
      ‘post_type’ => ‘feature’,
      ‘suppress_filters’ => TRUE
      );
      $found_posts = get_posts($args);

  • mimetic

    I am having trouble when I use tax_query. I have ordered posts, some of which are in a sub-category. While the posts in the main category are ordered as in the drag-drop interface, the posts in the sub-category are not appearing as ordered by the drag-drop interface! For example, I have
    “cat” as the main category, and “sub-cat” is a sub-category of “cat”. Posts only in “cat” are ordered, while posts in “sub-cat” are not.

    Your example, above, suggests the posts in the sub-category get their order from their inclusion in “sub-cat”, not by the drag-drop interface?!?

    Help!

  • ZaR

    Hi im Having problems with Advance Post – Re-order. im using w0o them & wooCommerce every time i do the manual sorting of a blog post & updated it & refresh the page the default order is back.

    • nspcode

      This must be caused by a JavaScript error produced by another plugin. Please check with your browser console for a message.
      If you can’t find the problem contact us and we will check into that for you.

      • ZaR

        I tried disabling all plugins except for the Adv. Post Order my Version 2.5.7.7