WordPress display read more in the entry footer

here is what I want to do:

I have a blog post which I want to display only to a specific point. So in the post I put

Read More
<!--more-->

on the right position.

My content.php looks like this:

<div class="entry-content">
    <?php the_content('read more'); ?>
</div><!-- .entry-content -->

<footer class="entry-footer">
    <?php mytheme_entry_footer(); ?>
</footer><!-- .entry-footer -->

The “read more” link gets displayed right after the content where it should be. But how can I display it inside the entry footer with the “Comment” link?

Is there a solution with the excerpt?

<?php the_excerpt(); ?>

I think this would even be better because I wouldnt need to put the line in every post.

Related posts

Leave a Reply

2 comments

  1. You can remove the ‘read more’ by using the following filter in your functions.php:

    add_filter( 'the_content_more_link', 'remove_more_link', 10, 2 );
    
    function remove_more_link( $more_link, $more_link_text ) {
        return;
    }
    

    Now you can create your own read more link inside entry-footer:

    <footer class="entry-footer">
        <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">Read more</a>
        <?php mytheme_entry_footer(); ?>
    </footer><!-- .entry-footer -->
    

    Edit:

    In comments below the following question was asked:

    I used the_excerpt() instead of the_content(). Is it possible to only display the link if the post is actually too long?

    You can do this by checking if the excerpt is different from the content. If this is the case (so there is more content than the excerpt is showing) you can show the read more link:

    <?php if ( get_the_content() != get_the_excerpt() ){ ?>
    
        <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">Read more</a> 
    
    <?php } ?>
    
  2. I use one workaround:

    //REMOVE 'MORE' LINK AND HARDCODE IT INTO PAGE - TEASER JUST PLAIN ELLIPSIS
    function modify_read_more_link() {
        if ( is_front_page() ) {
            return '...';
        } else {
            return '</div><footer class="clearfix"><a class="mg-read-more" href="' . get_permalink() . '">Continue Reading <i class="fa fa-long-arrow-right"></i></a>';
        }
    }
    add_filter( 'the_content_more_link', 'modify_read_more_link' );
    

    Explanation: for front page I have a short overview only clickable in the post title. And for blog list (after else in the above function.php ):

    <article>
      <header></header>
      <div>
        <?php the_content(); ?>
      </footer>
    </article>

    In which you can notice missing div closing and footer opening tags. It is a bit messi, but it brings the original WordPress Teaser into next division.

    Thankyou for reading.