Opened 10 months ago
Closed 5 months ago
#21436 closed defect (bug) (worksforme)
wp_query with custom post type and category not working
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 3.4.1 |
| Severity: | normal | Keywords: | reporter-feedback |
| 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
Change History (2)
comment:1
SergeyBiryukov — 10 months ago
- Keywords reporter-feedback added
comment:2
SergeyBiryukov — 5 months ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Feel free to reopen with more information if there's still a problem.

Couldn't reproduce on a clean install with Twenty Twelve.
My steps:
function bluestar_post_type() { register_post_type( 'bluestar', array( 'label' => 'Bluestars', 'public' => true, 'taxonomies' => array( 'category', 'post_tag' ) ) ); } add_action( 'init', 'bluestar_post_type' );$wp_query = new WP_Query(); $wp_query->query('post_type=bluestar&cat=-1&posts_per_page=-1'); ?>