I can’t get this example here to work!http://www.snilesh.com/resources/wordpress/wordpress-query_post-exclude-or-include-post-formats/
I’m trying to get any latest post that isn’t a “Video” post format. I’m not sure how I actually write the query once I’ve set the arguments up, at least I can’t get it to work. Here’s my code:
<?php
$args = array(
'tax_query' => array(
array(
'showposts' => '1',
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-video',
'operator' => 'NOT IN'
)
)
);
query_posts( $args );
?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<!--latest news-->
<div class="latestNews">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php if ( has_post_thumbnail()) : ?>
<a class="thumbnail" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
<?php the_excerpt(); ?>
<a href="?cat=1">more entries</a>
<a href="<?php the_permalink() ?>">read more</a>
</div>
<?php endwhile; ?>
I’m not sure if anyone can spot what I’ve done wrong there?! Would love any help possible!
Thanks
You are using
But you didn’t asign the object in the variable, it should be
But, I think it’s better to use
So, you can use
Solution: