WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi i am currently building upon a theme that i have build previously for my blog. The following code is to point to the latest post (the featured post). As this will have a different styling than all the other posts. However. I would like to filter out the post-format: links using the WP-Query i have defined within the loop since it brings me a lot more flexibility. How would i go around doin that?

 <?php $featured = new WP_Query();  $featured->query('showposts=1'); ?>
                    <?php while ($featured->have_posts()) : $featured->the_post(); ?>
                    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" class="maintitle"><?php the_title(); ?></a></h2>
                            <?php the_excerpt(); ?>
                            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="btn">Read more &raquo;</a> 

Best Regards Lucas

share|improve this question
do you mean "post_type"? – Chris Carson Aug 5 '11 at 14:54

You should be able to exclude posts with a specific format using WP_Query's tax_query parameter.


$q_args = array( 
    'posts_per_page' => 1, 
    'tax_query' => array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array( 'post-format-link' ),
            'operator' => 'NOT IN'
$featured->query( $q_args );

Untested, but should do the trick..

share|improve this answer
Sorry the code didnt function as needed i got an error from calling the query at line 16 Fatal error: Call to a member function query() on a non-object in /home/www/dechowmedia.com/wp-content/themes/portfolio/index.php on line 16 – user7686 Aug 6 '11 at 10:10
The code i posted should only replace the $featured->query('showposts=1'); part of your original code, incase that wasn't obvious/clear. – t31os Aug 6 '11 at 10:44
If you received the answer you were looking for, please mark this answer correct, and i welcome the edit as you were indeed correct regarding the term slug. – t31os Dec 9 '11 at 15:58

Your Answer


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.