I have a custom wp_query that loops through a post category 'case_study'. Here's that loop.
<?php
$args = [
'category_name' => 'case_study',
];
$query = new WP_Query($args);
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
?>
<a href="<?php the_permalink(); ?>" class="cell small-12 medium-6 large-4" data-equalizer-watch>
<div>
<div class="img-wrap" style="background-image:url('<?php the_post_thumbnail_url('full'); ?>');">
</div>
<div class="text-wrap">
<h4><?php the_title(); ?></h4>
<?php the_excerpt(); ?>
</div>
</div>
</a>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
The output I was expecting was this:
<a href="http://local:8888/title/" class="cell small-12 medium-6 large-4" data-equalizer-watch>
<div>
<div class="img-wrap" style="background-image:url('/wp-content/uploads/2019/01/Screen-Shot-2019-01-11-at-10.24.47-AM.png');">
</div>
<div class="text-wrap">
<h4>Case Study Title</h4>
<p>Excerpt text here.<a class="excerpt-read-more" href="http://local:8888/title/" title="title">… Read more »</a>
</p>
</div>
</div>
</a>
But instead it renders like this:
<a href="http://local:8888/title/" class="cell small-12 medium-6 large-4" data-equalizer-watch></a>
<div>
<a href="http://local:8888/title/" class="cell small-12 medium-6 large-4" data-equalizer-watch>
<div class="img-wrap" style="background-image:url('/wp-content/uploads/2019/01/Screen-Shot-2019-01-11-at-10.24.47-AM.png');">
</div>
</a>
<div class="text-wrap">
<a href="http://local:8888/title/" class="cell small-12 medium-6 large-4" data-equalizer-watch>
<h4>Case Study Title</h4>
</a>
<p>
<a href="http://local:8888/title/" class="cell small-12 medium-6 large-4" data-equalizer-watch>Excerpt text here.</a>
<a class="excerpt-read-more" href="http://local:8888/title/" title="title">… Read more »</a>
</p>
</div>
</div>
It works fine until I try and put in the_excerpt(). When I comment out the the excerpt I can actually see the commented out version looks normal but when I try to add the excerpt it does this. I don't understand why it's behaving so strangely and wrapping elements in the parent a tag?