Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#25647 closed enhancement (maybelater)

[WP_Query] Include post_type_query parameter to WP_Query

Reported by: alexvorn2's profile alexvorn2 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

My idea is to include a new parameter to WP_Query function that will be something like this:

$args = array(
	'post_type_query' => array(
		array(
			'post_type' => 'post',
			'tax_query' => array(
				array(
					'taxonomy' => 'people',
					'field' => 'slug',
					'terms' => 'bob'
				)
			)
		),
		array(
			'post_type' => 'book',
			'tax_query' => array(
				array(
					'taxonomy' => 'genre',
					'field' => 'slug',
					'terms' => 'comedy'
				)
			)
		),
		array(
			'post_type' => 'movie',
			'tax_query' => array(
				array(
					'taxonomy' => 'genre',
					'field' => 'slug',
					'terms' => 'comedy'
				)
			)
		)
	)
);
$query = new WP_Query( $args );

This will help to show multiple post types with specific taxonomies and terms without being in a conflict with each other...

Change History (5)

#1 @alexvorn2
11 years ago

  • Type changed from defect (bug) to enhancement

#2 @wonderboymusic
11 years ago

  • Keywords needs-patch needs-unit-tests added

I don't even want to wager how slow these queries would run

#3 @helen
11 years ago

I don't get it - why can't you just run separate queries and combine the results yourself?

#4 @wonderboymusic
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

If this is a feature you feel strongly about, come back with a patch or sample plugin. I don't see anyone else picking this up otherwise.

This ticket was mentioned in Slack in #core by boone. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.