I had trouble with a similar issue of sorting posts from a custom post type in a specified order on their archive page. I used http://wordpress.org/extend/plugins/sort-query-posts/.
The plugin lets you sort posts by author, comment_count, date, id, menu_order, modified, parent, or title. It only requires you to add the following lines
<?php query_posts(array('post_type'=>'post_type_name', 'posts_per_page' => 20)); ?>
<?php sort_query_posts_by('sort_type', 'order'); ?>
to your code, before the loop. Where ‘sort_type’ is the item by which your posts are sorted and ‘order’ is asc, desc, or rand. (very clear instructions in the short readme file).
Related Posts:
- Query all posts where a meta key does not exist
- Meta query with boolean true/false value
- Get post with multiple meta keys and value
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Can’t sort order of wp_query with 2 meta keys
- Query for posts from any post type but only add instock products
- WordPress Orderby Numeric Value Not Working
- Display custom post type from dynamic custom field
- WordPress request fiter order by related post’s post_title
- Displaying a div from an assigned meta_value when on a page
- How to get specific post meta by title or id
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- Returning a custom content types with meta values
- WP_Meta_Query object with conditionals
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Use WP_query to match post types based on custom field values
- How to sort by multiple values in a nested WP_Query
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to get post by meta value
- How do I get all authors posts of a custom post type outside loop
- Linking posts together with Advanced Custom Fields “both ways”
- How to get Current week and current date record wp query
- How to get post meta for custom post type and taxonomy
- get_post_meta for Custom Post Type ( CPT )
- WordPress custom post type
- Custom Post Type meta oembed html output resulting in WSoD
- Values inside a custom field to determine which category posts to display
- Querying meta values within an array
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- How can I filter posts by post_parent in the admin?
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- Compare 3 custom fields and sort by oldest
- Using Query Posts With Multiple Post Types And A Taxonomy
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- Custom Taxonomy List links being re-written
- How to get source of custom meta image?
- Displaying Meta Box Image
- Get count of custom post type created by current user
- Query Custom Post by Category
- Display posts if a custom field value is equal to another custom field value
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Custom post query by taxonomy
- Group custom posts by custom taxonomy names
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Setting proper query for multiple custom admin filters
- Custom meta box data array: foreach not working correctly?
- Query custom post type with tags
- How to check if user meta field is empty in conditional else statement
- Custom loop with multiple taxonomy queries
- How to do WP_Query with two meta fields with orderby clause
- Custom query at top of archive search page, arguments are overridden
- How to display post list inside post
- Advanced search form with filters for custom taxonomies
- Showing specific post in order of array wp_query
- WP the_posts() on single-cars.php get category link
- tax_query not working in template
- Submitting Custom Post Types with custom fields from Front-end form
- Custom WP_Query always respond with 200 status even when no entry
- Filter posts by tax (dropdown) and meta value
- Publish and save specific postmeta to a filtered post_type
- Pagination 404 on Index with custom query
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- Trying to add a class to post links
- Save CTP post meta different values each day without overwriting previous values
- Two queries – one with checkbox ticked, one without – comparing meta_query
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- posts_per_page in custom WP_Query does not override “Reading” settings?
- Display Parent-Child Posts in specific order by comparing IDs in array
- Apply category query clause to posts of custom type
- SEARCH QUERIES – REVERSE OUTPUT
- WP_Query to display number of custom post type filtered (order by) taxonomy
- Where is get_post_meta value located?
- 2 modal windows with ACF content on Archive page
- post_type incorrect for custom post type
- Live search by custom tag
- Custom Post Type – Display all, wrap in groups of 3
- How to save post_status using action save_post?
- How to get the posts that my following users are liked?
- Only show categories that have posts within custom post type
- Custom post meta box as a sub form
- Custom meta box data not saving
- Storing data in a multidimensional array from dynamically generated foreach loop
- Display all Custom taxonomy terms and their relevant custom posts
- How To Loop Through list with Custom Post Types
- CPT or Custom Table for Repository of Serial Numbers
- Query Pulling the same post twice
- Custom Post Type + Category archive
- Pop up showing same content on all posts display.
- Custom post-type’s pagination not working in category.php
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Count of posts with meta_key filled in?
- Save post_parent in a custom post type
- Are custom posts included when getting a categories’ posts?
- Query order by meta value force specific tag first
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- How do I get parameters from the URL?