How to order WordPress Posts using a Custom Field value

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

Order the WordPress custom post types by a Custom Field value has never been easier since the latest version of Advanced Post Types Order plugin. Forget about long codes, template files, error messages and lots of tries, just use a simple interface, chose the options and the plugin does the work for you on the fly! Yes, that’s right you don’t need to know anything about programming to control that.

Here is the simple way to follow to achieve this:
Within the custom post type re-order interface chose the required Taxonomy, in our case Categories, then select a Term, in my example a category named Culture / Entertainment.

Chose Automatic Order and select the Custom Field option from the list. In the Custom Field Name type in the post meta name you need to sort on

advanced-post-types-order-custom-field-usage

Click Update and you are done.


Subscribe
Notify of
guest
27 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Tim

Is this functional for any post types or only for Posts?

nspcode

This will work for any WordPress custom post types, either default (post, pages) or custom defined.

daniel_c_long

If I’ve created my post types using the WordPress register_post_type() function, is there a parameter I need to add in to that code to allow your plugin to work?

nspcode

There are no additional requirements for the Advanced Post Types Order plugin to work with your custom post types no matter the way you create those, either through code using register_post_type() or by using a custom plugin

daniel_c_long

Thanks for your reply.

That’s odd, the post types I’ve created using Custom Pot Type UI plugin show the re-order menu, but the ones I’ve created using a function don’t and not sure why.

nspcode

You must be using the wrong hooks to register your post types, check this page for more info

daniel_c_long

Yea, thats what I’m using. The problem was my post type was set to ‘hierarchical’ => true, when it needs to be ‘hierarchical’ => false.

May have been my error if this is in the plugin documentation.

nspcode

Daniel are you sure you use the Advanced Post Types Order plugin? As it support both hierarchical and non-hierarchical structures.

Javier Ordinola

The hierarchical only work with the premium version.

ddd

Hi,

I use wordpress 3.5.1

I have this error when i click the update button to reoder my custom type post in admin (wp-admin/load-script.php – jQuery v1.8.3) :
Error: cannot call methods on sortable prior to initialization; attempted to call method ‘serialize’

Can you help me ?

nspcode

Hi,
Please download the latest plugin files using the personal link you got when bought the plugin which will fix the problem.

ddd

Hi,

It resolved the problem,

thanks

jeremiah

Will this support sorting by custom attributes?

nspcode

Presuming your attributes are saved as postmeta data (however there is no other way to do that by WordPress default) you will be able to sort by that.

Mark

Hi, I have added this plugin and reordered using tags but for some reason it is still not reordering in the way I’d like; only in descending date order. Any ideas why? http://roselandonline.co.uk/Cornwall_Roseland_Peninsula/arts-crafts/

nspcode

Hi Mark,
Is the Autosort functionality set as ON? Otherwise try to include ‘orderby’ => ‘menu_order’ within your theme file query. More details can be found at https://www.nsp-code.com/advanced-post-types-order-api/sample-usage/
If still not working please get in touch with use through contact and we will check into this.

moonmist

The new posts are going to the bottom of the sorted list, how do I place them at the top?

nspcode

Check with this post https://www.nsp-code.com/advanced-post-types-order-description-and-usage/understanding-sort-list-settings-area/ at “Send new items to bottom of list” this need to be set for No.

ali eliad

can I add a header and a picture to every title?

nspcode

If you mean to create a header and picture information for every post as custom fields, then sort by those, Yes it will work.

Pete Lihou

When I try to activate, I get the following error, can you help please?

Fatal error: Cannot redeclare cpto_activated() (previously
declared in
/home/content/04/7091804/html/awards/wp-content/plugins/advanced-post-types-order/advanced-post-types-order.php:44)
in /home/content/04/7091804/html/awards/wp-content/plugins/post-types-order/post-types-order.php on line 23

nspcode

You need to de-activate the free Post Types Order plugin before use the paid code.

Pete Lihou

Post Types Order is already de-activated, are you saying I should delete it?

nspcode

The error message say that it’s still active. Please double check on that. If still not working, yes try to delete.

Pete Lihou

I’ve now deleted it and have succesfully de and re activated Advanced Customer Posts. I have an outstanding issue that it won’t recognise and auto sort on a custom field. The website is http://thebookawards.com/awards/current-voting/ and I use a plugin called Post Ratings for up to 5 star ratings for each post. There’s a Top Posts sidebar which picks up the highest voted posts and lists them and the ‘votes’ custom field shows as an option when I display custom fields. However, if I select it Advanced Post Types doesn’t list any of my posts. I thought that re-activating might help but it hasn’t. Can you help please?

nspcode

We already checking into this, per yesterday support request through contact. Let me ask the support member to send a progress to your e-mail.