Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm facing a strange problem:

  <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 10 ) );
              while ( $loop->have_posts() ) : $loop->the_post(); ?>

(...)

              <?php endwhile; ?> 

This code displays all posts of "ff" type. Works fine.

But I do not want to list all posts of this type, I just want the ones that are in "ff_show" category (so the slug/term is "ff_show).

Codex tells me that I should use 'category_name' but when I do the loop is always empty:

  <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'category_name' => 'ff_show',  'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 10 ) );

I've tried typing everything after 'category_name', nothing works.

The funny thing is when I use category instead of category_name - it ALWAYS shows all the posts. No matter what ID I give.

Am I doing something wrong?

I'm sure about my category name, it is exactly as I said.

When I login to my panel admin and go to categories and hover over one of them it points to:

http://localhost/wordpress/wp-admin/edit-tags.php?action=edit&taxonomy=frontpage_categories&post_type=ff&tag_ID=19

BUT 'cat' => '19' shows nothing.

:/

share|improve this question
    
What makes you think the cat parameter would work on the edit-tags page? Why does it need to? –  t31os Dec 18 '10 at 20:45
add comment

1 Answer 1

up vote 1 down vote accepted

Are you absolutely sure ff_show is correct slug? I have suspicions about that underscore...

category is not valid query argument at all, it is probably simply discarded.

Had you tried this query with id instead of slug? cat argument.

Edit.

Wait, you are trying to query custom taxonomy? Category arguments have no relation to it at all.

Try frontpage_categories => ff_show (quick guess, don't remember specifics of querying custom stuff. again - not my area).

Yeah, found it at last Custom Taxonomies > Querying by Taxonomy

share|improve this answer
    
Updated. Nothing :( Anyways - is my code valid and should work? If it is then I'll search somewhere else... –  Wordpressor Dec 18 '10 at 20:20
    
I am not sure about how post_type interacts with stuff (custom posts are not my area really), but I can't spot anything out of order with code so far. Can you simply query for category without rest of arguments? –  Rarst Dec 18 '10 at 20:24
    
new WP_Query( array( 'post_type' => 'ff', 'category_name' => 'ff_show' ) ); - gives no results. I'm really 100% it's named that way because I'm just looking at category tables ;/ –  Wordpressor Dec 18 '10 at 20:29
    
try changing category_name to category. custom post types should take the taxonomy term name as argument –  onetrickpony Dec 18 '10 at 20:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.