Opened 11 years ago
Closed 11 years ago
#21436 closed defect (bug) (worksforme)
wp_query with custom post type and category not working
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4.1 |
Component: | Query | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
I have declared a custom post type in my theme called bluestar. There are some posts i dont want displayed on every page display those posts so i added support for categories in my register_post_type function using this solution http://bit.ly/bVazBo
'taxonomies' => array('category', 'post_tag')
Using wp_query i am able to output posts that are from that post_type and are not in that category using cat-id which works
<?php $wp_query = new WP_Query(); $wp_query->query('post_type=bluestar&cat=-19&posts_per_page=-1'); ?>
The issue occurs when you try to do the reverse and only output posts from from the bluestar post_type that ARE in a specific category.
I have tried two methods both dont work
Method 1 using astraight query like before:
<?php $wp_query = new WP_Query(); $wp_query->query('post_type=bluestar&cat=19&posts_per_page=-1'); ?>
Method Two Array
<?php $wp_query = new WP_Query(); $wp_query->query(array( 'post_type' => 'bluestar', 'cat' => 19, 'posts_per_page' => -1)); ?>
I have tried several variations but nothing seems to work so i believe its a bug. I have tested this in all modern browsers on a mac running mac osx mountain lion. I also have tried deactivating all plugins but it still persists. I am using the latest version of wp (3.4.1)
Please advise
Thanks
-Yosef
Couldn't reproduce on a clean install with Twenty Twelve.
My steps:
cat=-1
withcat=1
.