Opened 7 years ago
Closed 6 years ago
#47614 closed defect (bug) (invalid)
The meta_query of wp_query only support type of 'post'.
| Reported by: | issaczhuang | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | close reporter-feedback |
| Cc: | Focuses: |
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 );
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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_sqlmethod 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->postsis 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/.