Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#27275 closed defect (bug) (invalid)

custom post, custom tax and category or post_tag

Reported by: aliwebdesarrollo's profile aliwebdesarrollo Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Query Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I was developing a new theme when i try to create a wp_query for a custom loop.

I create a custom post type
http://generatewp.com/snippet/lNKnjp4/

Custom taxonomy

http://generatewp.com/snippet/7QkXvPk/

WP_query

http://pastebin.com/rRSzyMKw

I was trying to get custom post, with a particular custom_taxonomy and a particular category

When i make a var_dump i found that the parameters of the wp_query where modify by the core, changing from 'my_custom_post' to 'post'.

I try it removing the category filter from the args (i keep the custom post type and custom tax) and the query i get was the right one without the filter i need.

this is the dump i have when i have the category__in filter into args

http://pastebin.com/kTkJWL8n

as you could see the post_type was change from 'publicidad' to 'post'

this is the dump without the category__in filter

http://pastebin.com/CapQQ0Ge

Change History (7)

#1 follow-up: @wonderboymusic
11 years ago

  • Component changed from General to Query
  • Focuses ui template performance removed
  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 3.9

The appearance of any in the post_type array is scary.

#2 in reply to: ↑ 1 @aliwebdesarrollo
11 years ago

Replying to wonderboymusic:

The appearance of any in the post_type array is scary.

Yes i know but i put it to test, i also try only with my custom post type, i was trying to find if i put any the query change in any aspect.

#3 @aliwebdesarrollo
11 years ago

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

#4 @aliwebdesarrollo
11 years ago

I found that inside a setting file (not a plugin because this theme doesnt have it) it was set this:

$query->set( 'post_type', 'post' );

I spent 4 days trying to find out where it was the problem, and as i was creating a new query outside the main loop i belive that this set not affect the new query.

#5 @helen
11 years ago

  • Keywords needs-patch needs-unit-tests removed
  • Milestone 3.9 deleted

#6 @SergeyBiryukov
11 years ago

  • Description modified (diff)

#7 @aliwebdesarrollo
11 years ago

Just to know, aparently the problem was that inside a function in functions.php it was setting when it was a query of category the post_type to "post", without taking in count if its a new wp_query or it the original from the main loop.

Note: See TracTickets for help on using tickets.