The reason is :
My custom post type is “order”
So $args['post_type'] = "order"
And $args['order'] = "asc"
And for some reason WP_Query
made wp_posts.post_name="asc"
I fixed this adding a prefix for my custom post type name like
foo-order
so$args['post_type'] = "foo-order"
Related Posts:
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Query to get the author who having maximum number of post (custom post type)
- Including metaboxes from custom post types in global search — continued
- A faster way to query custom post types with multiple conditions?
- Custom post order when using OR relation
- This wp_query will not return any posts and only seems to work with post_status inherit?
- Display all posts in a custom post type, grouped by a custom taxonomy
- Query by post title
- Get post with multiple meta keys and value
- Get posts for custom post type with WP_Query
- WP_Query() show posts that end later than today
- Sorting a query by custom field date
- Number of pages – multiple (custom) post types
- Enforcing canonical URLs with multiple custom post types
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Get latest 4 post on a custom post filtered by category
- how to group custom post type posts by custom taxonomy terms
- How to sort CPT by custom meta value (date), and return posts month by month
- wp_query and comment_parent – select only posts with top level comments
- Comparing timestamps in meta query doesn’t work
- Include both default and Custom Post Type in query modified inside pre_get_posts
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- List all custom post type posts from a given category?
- Exclude current post when getting related post on custom post type and taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Filter posts with meta_query NOT IN where value has multiple values
- How to query different post types in specific order?
- Loop on front-page.php
- Querying Term Posts in Loop
- is_main_query() not working for WP REST API
- Can’t get order_by meta_value_num to work properly
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Loop through Custom Post Type, and then show children within each iteration
- orderby in custom WP Query does not work
- Unable to retrieve any posts of CPT in wp-admin
- Linking to the most recent post in a Custom Post Type
- How to make sure content doesn’t display if selection is empty
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Creating a navigation menu of all posts of a custom post type and their children posts?
- Wp_query: sort by PHP variable
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Crafting WP_Query array, sort by date
- forming WP_Query for posts of all post types but from specific categories
- How can I get the number of custom post type posts that have a specific attachment image set?
- Custom Widget WP_Query problem
- Order posts by 2 custom fields and if one custom field is zero orderby another custom field
- WP Query post__in not returning correct results
- Proper way to display latest 5 posts grouped by post type?
- Detect inside a custom query the kind of post type to assign custom classes
- Custon Content within WordPress Loop
- get_pagination not working on a custom post type query (using WP_Query)
- WP_Query with custom post type ID
- Query all post and CPT from 2 specific taxonomies AND by ACF custom field
- WP_Query order by two values
- How to Query in WordPress which shows Alphabetic Posts?
- postsperpage value not being applied
- Exclude latest post from WP_Query taxonomy term loop
- Getting titles from an array of IDs
- wp_dropdown_pages with tax_query clause
- Cache issue with WP_Query and custom field filtering
- Post Type => Any conundrum
- Display featured posts for a custom post type by taxonomy
- What is the most efficient way to execute recursive complex queries?
- date_query empty results with custom post type
- conditional filter
- Alike Shortcode using in Custom Shortcode
- have to do a while have post to show for two custom post types sharing the same taxonomy?
- display post count in archive page that have relation with another taxonomy term
- How can I sort the results of a REST API response by the title of a connected custom post type?
- Query when is one or several values
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- Help understand and create a loop with WP_query
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- WP_Query for custom taxonomies showing posts from non-specified terms?
- how to display new private message to users?
- Make pagination work as a carousel (custom query)
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- Search result based on URL
- subtracting the current post form then whole loop, which is generating all CPT titles
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Imported Content Doesnt Show Up On Frontend
- Loop carousel slider in wordpress
- Manually build WP_Query
- Loop with Custom Post Type and Taxonomies
- New WP_Query not isolating custom post types on front-page template
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- 404 on Pages for Custom Post Type & Query_Posts
- Pagination not working on homepage
- How to query custom post then display sections by meta value
- Using tax_query to get single post per category
- Show Posts in Vertical Tabs with Scrollbar
- How to manage wordpress knowledge base/wiki/posts collections
- Is it possible to make is_category() recursive?
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Default WordPress Query for a Specific Custom Post Type URL
- Sort ACF by custom taxonomy
- Dynamically count the number of custom post types associated to a custom taxonomy