1

I intend to show an excerpt of each post on my homepage. I use the_excerpt() in my post.php to show an excerpt of each post with a read more button below it. The problem is that I need to have the readmore link in another div (the category metadata div) so that they are inline with each other. That way I can style them easily. So far, I have tried with no success to, first, strip the original the_excerpt's readmore link and then provide each post with another link in the other div.

Please kindly let me know if the above strategy is the right way to do so, and help me find the solution to this problem.

UPDATE:

To remove the readme link, I had to use the_content() instead of the the_excerpt():

<?php the_content('', TRUE); ?>

Though I have gotten rid of the original readmore link, I have no idea, how I can add a separate readmote link for each post in front of the intended div.

The code in my post.php file:

<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
        <section>
                <?php get_template_part( 'templates/part', 'title' ); ?>
                <?php get_template_part( 'templates/part', 'postmetadata' ); ?>
                <?php if(has_post_thumbnail()) { ?>
                                <figure class="theme-post-media">
                                        <a><?php the_post_thumbnail( 'full', array( 'class' =>'img-responsive' ) ); ?></a>
                                </figure>
                <?php } ?>
                <?php the_excerpt(); ?>
        </section>
       <div class="postcatmeta">
                        <?php get_template_part( 'templates/part', 'postcatmeta' ); ?>
        </div>
</article>
  • Can you post what you tried? – Howard E Jun 19 '16 at 11:34
  • No ideas anyone? – developer Jun 24 '16 at 9:12
1

Remove the read more with this code in your functions.php:

function wpse_230169_excerpt_more($more) {
    return '';
}
add_filter('excerpt_more', 'wpse_230169_excerpt_more');

Then in your template file just add the link wherever you want with:

<a href="<?php the_permalink(); ?>">Read More</a>
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.