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 feel like I've been banging my head against the keyboard for a week with this problem. I'm trying to change my current query on my home page to show only posts that are set as standard posts using the new post format.

I've looked everywhere for answers (including here and here) and tried everything I've found, but I can't get it to work within the framework of my current query.

My query is provided below. Any help is greatly appreciated.

<?php     
query_posts( array( 'post__not_in' => $ids, 'showposts' => 10, 'cat' => '-4' ) ); ?>
<?php while (have_posts()) : the_post(); ?>
-LOOP STUFF-
  <?php the_excerpt(); ?><BR>
<?php endwhile; ?>

UPDATE - March 30: Since I posted this I found out how to properly query for, we'll say, image posts using this code:

    <?php 
$args = array(
  'post__not_in' => $ids, 
  'showposts' => 10, 
  'cat' => '-4,-1866,-27',
  'tax_query' => array(
    array(
      'taxonomy' => 'post_format',
      'field' => 'slug',
      'terms' => 'post-format-image'
    )
  )
);        
    query_posts( $args ); ?>
<!-- Look Stuff -->
    <?php endwhile; ?>

But I still need to figure out how to do the opposite and only pull standard posts.

Second Update - March 30: I found the answer after some more hunting. Apparently the only way to pull the standard posts is to add:

'operator' => 'NOT IN',

So it looks for posts that aren't in the image post format. Or I have to add an array of terms to the terms line so it won't return any of those formats. Odd, but it works.

share|improve this question
    
As a minor addendum, perhaps the site needs a tag for post format now? –  Andrew Mar 22 '11 at 16:53
2  
you dont need to exlclude all other posts formats just use 'tax_query' => array( array( 'taxonomy' => 'post-format', 'field' => 'slug', 'terms' => array( 'post-format-quote' ) ) ) to get only your wanted post type –  Bainternet Mar 22 '11 at 17:14
    
Where's the post format specific code in your query then? +1 Bainternet.. –  t31os Mar 22 '11 at 17:14
    
@Bainternet I haven't been able to get the tax_query to work for me with the query I use above. If you can be specific it would be helpful. –  Andrew Mar 23 '11 at 18:43
    
Just a heads up the codex was wrong the other day, I think it is now changed, it is 'taxonomy' => 'post_format' . Underscore not hyphen. This is for Bainternet's comment , it looks right in your code. –  Wyck Mar 30 '11 at 16:54
show 1 more comment

1 Answer

up vote 0 down vote accepted

Okay, I found the answer after some more hunting. Apparently the only way to pull the standard posts is to add:

'operator' => 'NOT IN',

So it looks for posts that aren't in the image post format. Or I have to add an array of terms to the terms line so it won't return any of those formats. Odd, but it works.

<?php 
$args = array(
  'post__not_in' => $ids, 
  'showposts' => 10, 
  'cat' => '-4,-1866,-27',
  'tax_query' => array(
    array(
      'taxonomy' => 'post_format',
      'field' => 'slug',
      'terms' => 'post-format-image',
      'operator' => 'NOT IN'
    )
  )
);  
    query_posts( $args ); ?>
<!-- The Loop -->
    <?php endwhile; ?>
share|improve this answer
    
Unfortunately, as I understand tax_query, doing a NOT IN query to exclude all formats except for the standard one would be an extremely slow performance-wise. –  Weston Ruter Sep 20 '12 at 21:25
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.