Não consigo exibir a mensagem do else quando não há posts no loop:
Meu código:
<?php if(have_posts()); ?>
<?php while(have_posts()):
the_post(); ?>
<div class="noticias-categorias-item">
<?php
the_post_thumbnail('medium', array(
'class' => 'img-responsive'
)); ?>
<div class="post-inf">
<div class="tag-categoria">
<?php the_category();
term_description(); ?>
</div>
<a href="<?php the_permalink(); ?>">
<h2><?php the_title(); ?></h2>
<p class="data-post"><?php echo get_the_date(); ?></p>
<p><?php the_excerpt(); ?></p>
</a>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h1>Nada encontrado!</h1>
<?php endif; ?>
Erro exibido:
Parse error: syntax error, unexpected 'else' (T_ELSE)
Agradeço desde já a ajuda!