Opened 16 months ago
Last modified 16 months ago
#47614 new defect (bug)
The meta_query of wp_query only support type of 'post'.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Query | Keywords: | close reporter-feedback |
Focuses: | Cc: |
Description
The meta_query of wp_query only support type of 'post'.
On class WP_Query line 2269.
I could not use the meta_query if I register other types of 'post_type'.
$clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this );
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hello @issaczhuang, welcome to Trac and thanks for reporting an issue.
It's hard to say why you can't get your meta query to work with so little information, if that is the situation.
To say that meta queries only work for post type "post" is not correct. Sites and developers depend on that all the time.
In the line you are quoting, parameter 1 for the
get_sql
method is the object type, not the post type. Object types are "post", "user", "term", "comment" and such that have a meta table in the database.$wpdb->posts
is the main table for all post types.Unless you have further information indicating a bug in WordPress Core, I have to recommend this ticket closed as invalid. If you need help getting your queries to run, please post in our support forums https://wordpress.org/support/forums/.