Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#12744 closed defect (bug) (fixed)

Querying with post_type and a taxonomy

Reported by: kovshenin Owned by: ryan
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Query Keywords: has-patch tested commit
Focuses: Cc:


Kind of weird. I've got a custom post type called property (real estate) and I'm able to use the post_type=property query to grab them. Now if I add some taxonomy to the query, such as post_type=property&location=italy then I'm left with all post types from italy, i.e. including posts.

The post_type parameter is being ignored and forced to any on line 2041 in query.php.

I also noticed that around line 1631 it's being forced again to any if we're doing a search, so a search with post_type=property will probably not work.


Attachments (1)

query.php.diff (539 bytes) - added by kovshenin 6 years ago.
Maybe this could work

Download all attachments as: .zip

Change History (5)

6 years ago

Maybe this could work

#1 @scribu
6 years ago

  • Keywords has-patch added
  • Milestone changed from Unassigned to 3.0

#2 @scribu
6 years ago

  • Keywords tested commit added

Seems to be working. This is what I used:

function debug_query() {
	register_post_type('test', array('public' => true));

	register_taxonomy('genre', 'test');
	register_taxonomy_for_object_type('genre', 'post');
add_action('init', 'debug_query');

Going to ?genre=foobar&post_type=test gives the expected results.

#3 @scribu
6 years ago

Related: #12750

#4 @markjaquith
6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Looks like it was fixed by [14478]

Note: See TracTickets for help on using tickets.