Make WordPress Core

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: issaczhuang Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Query Keywords: close reporter-feedback
Focuses: Cc:


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)

#1 @knutsp
16 months ago

  • Keywords close reporter-feedback added
  • Version 5.2.2 deleted

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->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/.

Last edited 16 months ago by knutsp (previous) (diff)
Note: See TracTickets for help on using tickets.