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 ignore_custom_sort parameter will help
*Since version 3.5.2 ignore_custom_sort replaced the force_no_custom_order
$args = array( 'post_type' => 'feature', 'orderby' => 'rand', 'ignore_custom_sort' => 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..) }
In case of multiple sorts which contain the same query settings, the first will apply. However this can be modified by including the ‘sort_id’ parameter, where the value is the Sort post Id.
$args = array( 'post_type' => 'feature', 'orderby' => 'menu_order', 'sort_id' => '4211', ); $my_query = new WP_Query($args); while ($my_query->have_posts()) { $my_query->the_post(); //(..your code..) }
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 ?
Yes that is correct. This parameter will allow to control the order as default/custom independently of the Autosort status.
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!
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.
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.
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.
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?
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);
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!
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.
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.
I tried disabling all plugins except for the Adv. Post Order my Version 2.5.7.7
Please contact us at contact@nsp-code.com and we will check into this.
I am trying to use manual sorting, and a 3rd party taxonomy. I stripped everything down to just a simple get_posts with the tax query and still don’t understand why the manual sorting from the admin isn’t showing up on the front end.
$args = array(
‘post_type’ => ‘attachment’,
‘post_status’ => ‘inherit’,
‘posts_per_page’ => ’50’,
‘orderby’=>’menu_order’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘media-tags’,
‘field’ => ‘slug’,
‘terms’ => ‘jason-test’
)
)
);
In admin, I created and saved a manual sort for this specific tax query, I even tried adding ‘sort_id’=>’2143’ to the query array, as that is the ID of the sort, and still nothing happens. Can post link to test page if needed
You should use a custom query instead please check at http://codex.wordpress.org/Class_Reference/WP_Query
The get_posts() does not allow filters to trigger. If you keen to use that, please include the ‘suppress_filters’ => false within your $args array
Thanks for getting back to me quickly! I tried ‘suppress_filters’ => false, and it doesn’t produce the desired results. I also noticed that if I suppress filters, it reverts back to the original upload order. Should I try not to use sort_id and let the tax matching do it’s thing?
If you thing get_posts() is getting in my way, I will work on switching to wp_query (I tried this already but got stuck elsewhere).
using wp_query got me what I was looking for, so no need to reply.
I got the exact same problem. The reordering does not happen at all. Funny enough, it is on a multisite, where ordering works on the root blog, but on other blogs it simply ignores all my efforts! :-/
This should work fine, can you make sure you use the latest plugin version which currently is 3.8
If still not working, please use the contact form and someone will assist with this issue.
OK so even using a base wp_query, the issue occurs when I use multiple taxonomies:
$args = array(
‘post_type’ => ‘attachment’,
‘post_status’ => ‘inherit’,
‘posts_per_page’ => ‘1000’,
‘orderby’=>’menu_order’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘media-tags’,
‘field’ => ‘slug’,
‘terms’ => array(‘jason-test’,’portfolio’),
‘operator’ => ‘AND’
)
)
);
I get the right images, but they are no longer in the manual order, even though I’ve updated the manual order to include both ‘jason-test’ and ‘portfolio’. Taxonomy relationship is set to ‘AND’. Ideas?
Not sure what to here, I’ve been experimenting with different ways to attack this and nothing seems to work
Is it possible to limit posts to only direct children within a category? Now I also get all posts that live in subcategories (posts are woocommerce products)?
You can do that by creating an advanced sort see https://www.nsp-code.com/advanced-post-types-order-description-and-usage/create-sort-for-mix-of-single-multiple-custom-post-types-taxonomies-authors/ So include the category you need and exclude the other child terms. Then on front side create a similar query, where include the category and exclude the others http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
If can’t figure out, please contact us and a coder will check into it for you.
Thanks! I will try this in the coming days. Also this answer might be of help: http://wordpress.stackexchange.com/a/143048, but then maybe for adding it as a feature?
Actually this will achieve similar results as my solution. However we intend to implement the ‘include_children’ argument which will makes that easier.
It does not look like it is possible to nest taxonomy queries in the admin. Will this be included in a future release? Also, is there a way to tie a custom query in my theme to a sort list ID and override the query rules? This way I could run more complex queries without being restricted by the query rules set in the sort list settings.
Nested taxonomies are not fully supported, not through visual interface. You can always use the apto_interface_query_args filter and adjust the sort query to match your scenario.
Thank you! I had success with the apto_interface_query_args filter. Snippet here -> https://gist.github.com/epierpont/d21ea29e16af93218ac32148538efff7
Hi! Have some problem My Blog contain more than 10 000 posts and when I try sort posts by one page – work perfect, but I can’t drag post from 2 page to 1. E.g. Have old post on queried 15 page, sort work only on this page, I can’t move post from 15 page to 1. How can I do that?
Hi,
Did you use the pagination functionality as explained at this article https://www.nsp-code.com/pagination-for-large-sort-lists/
Can you check your browser console for any JavaScript errors?
If you can’t figure out, please get in touch through contact for a fast help.
Thanks
Hello! It doesn’t seem to work with WP-Views plugin. I’ve disabled auto-sort and set view to use Menu Position ASC sorting, and it doesn’t catch up. Any ideas?