0
I created a Query post for a certain category
<div class="querypost-home" id="conteudo-home4">
<?php
$args = array(
'category_name'=>'oportunidades',
'numberposts'=>1,
'offset'=>3
);
$my_posts = get_posts($args);
if( $my_posts ):
foreach( $my_posts as $post ) : setup_postdata($post); ?>
<?php if ( has_post_thumbnail()) : ?>
<div class="img1"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(870,420)); ?></a></div>
<?php endif; ?>
<div class="titulo-query-home"><a href="<?php the_permalink(); ?>"><p><?php title_lenght(40) ?></p></a></div>
<div class="resumo-query-home"><p><?php echo get_excerpt(160); ?></p></div>
<?php
endforeach;
else:
?>
<p></p>
<?php endif; ?>
</div> <!-- query post -->
I put a class in this query so I can put a nice style in these query posts. When I don’t add any posts, the BG of the query still appears, but without content. Does anyone know how to hide query when they don’t have any posts in their offset ?