Make WordPress Core

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 );

Change History (2)

#1 @knutsp
7 years ago

  • Keywords close reporter-feedback added
  • Version 5.2.2

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 7 years ago by knutsp (previous) (diff)

#2 @hellofromTonya
6 years ago

  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status newclosed

I'm closing this ticket as it's been 18 months since reporter feedback was requested and marked as a close candidate. If this issue still exists, please provide feedback for further investigation.

Note: See TracTickets for help on using tickets.