In the docs it states that you need to pass get_tag_link()
an argument, which is the tags ID, but I need to be able to access this during the loop
.
Maybe I'm using the wrong function here. I'm trying to wrap an image with an <a>
tag that is supposed to represent the tag.
And yea, only passing it a variable ($tag_id
) isn't going to do the trick but I'm not sure how I should represent the $tag_id
to account for the loop.
Look in the start of the HTML
from the echo
, article > header
you will see an <a>
that is wrapping the the_post_thumbnail([300, 200])
.
if (have_posts()) {
while (have_posts()) {
the_post();
echo '
<article class="blog-post col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-0 col-lg-4 mb-5 mb-md-0">
<header class="col-12 mb-3 text-center">
<a href="',get_tag_link($tag_id),'">',the_post_thumbnail([300, 200]),'</a>
</header>
<div class="col-12 mb-3 text-center">
<small>',the_category(' '),'</small>
</div>
<div class="col-12 mx-auto mb-3">
<h2 class="h2">
<a href="',the_permalink(),'">',the_title(),'</a>
</h2>
</div>
<div class="col-12 mx-auto mb-3">
<p class="lead">',the_excerpt(),'</p>
</div>
</article>
';
}
}