Filtering post-formats from the loop using new WP-Query();

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

Related posts

Leave a Reply

1 comment

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

    Eg.

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

    Untested, but should do the trick..