0

The following code is a template-part which I use to display post excerpts. I want to wrap the link around the whole post excerpt but instead it gets replicated inside each element as seen in the screenshot.

content.php

<a href="<?php the_permalink(); ?>">
<article class="article-container">

 <div class="post-header">
    <h2><?php the_title(); ?></h2>
    <div class="post-meta">
        <div class="post-date"><?php the_time('j. F, Y'); ?></div>
        <div class="post-category"><?php the_category(' '); ?></div>
    </div>
 </div>

 <div class="post-content">
 <?php if (has_excerpt()) { the_excerpt(); } ?>
 </div>

</article>
</a>

*edit

This code pulls in the loop

index.php

    <?php if ( have_posts() ) :
        while ( have_posts() ) : the_post();
        get_template_part( 'content', get_post_format() );
        endwhile;
        wp_link_pages();
    endif;
    pagination($pages = '', $range = 2);
    ?>

source code

2
  • That should work... Semantically its not the best approach, but should work. What else do you have going on in that theme?
    – ngearing
    Dec 20, 2016 at 22:37
  • how would you solve it semantically? I added the code that pulls in the loop
    – MrKainig
    Dec 21, 2016 at 19:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.