I have a problem with the way WordPress creates code.
As shown below, my articles should be wrapped inside an <a>
tag. WordPress creates a few extra wraps and I don’t know how to get rid of them.
Does anyone has an idea?
This:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="post-thumb">
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) {the_post_thumbnail();} ?>
<div class="post-thumb-caption">
<h2><?php the_title(); ?></h2>
</div>
<div class="post-thumb-caption-hover">
<div class="post-thumb-caption-hover-center">
<img id="menu-icon" class="icons svg" src="icons/menu21.svg"></img>
<h2><?php the_title(); ?></h2>
<h3><?php the_category(', ') ?></h3>
</div>
</div>
</a>
</article>
<?php endwhile; ?>
<?php post_navigation(); ?>
<?php else : ?>
<h2><?php _e('Nothing Found','html5reset'); ?></h2>
<?php endif; ?>
Should result in this:
<article class="post-thumb">
<a href="#">
<img src="3a.jpg" id="image">
<div class="post-thumb-caption">
<h2>Titel</h2>
</div>
<div class="post-thumb-caption-hover">
<div class="post-thumb-caption-hover-center">
<img id="menu-icon" class="icons svg" src="icons/menu21.svg">
<h2>Titel</h2>
<h3>Categorie</h3>
</div>
</div>
</a>
</article>
But WordPress creates this:
<article class="post-thumb">
<a href="http://localhost/sm/titel/">
<img width="300" height="300" src="http://localhost/sm/wp-content/uploads/2014/08/3a.jpg" class="attachment-post-thumbnail wp-post-image" alt="3a"> <div class="post-thumb-caption">
<h2>Titel</h2>
</div>
</a><div class="post-thumb-caption-hover"><a href="http://localhost/sm/Titel/">
</a><div class="post-thumb-caption-hover-center"><a href="http://localhost/sm/Titel/">
<img id="menu-icon" class="icons svg" src="icons/menu21.svg">
<h2>Willem en Henk</h2>
</a><h3><a href="http://localhost/sm/Titel/"></a><a href="http://localhost/sm/category/ontbijt/" title="Alle berichten bekijken in Ontbijt" rel="category tag">Ontbijt</a>, <a href="http://localhost/sm/category/snacks/" title="Alle berichten bekijken in Snacks" rel="category tag">Snacks</a></h3>
</div>
</div>
</article>
Change
to
and it should fix that problem.