Force a Read More Link on all Post Excerpts in WordPress

Can’t see a read more link on a WordPress post on the blog page?  The read more link can be forced on all excerpts for posts on an archive page by adding the following code to your theme. Sometimes the read more wont show due to a shortfall of characters or an element like an iframe sitting at the top of the post.

//Read More Button For Excerpt
function themeprefix_excerpt_read_more_link( $output ) {
	global $post;
	return $output . ' <a href="' . get_permalink( $post->ID ) . '" class="more-link" title="Read More">Read More</a>';
}
add_filter( 'the_excerpt', 'themeprefix_excerpt_read_more_link' );

Just pop this into your functions.php and you should be golden!

You can add CSS class and HTML to suit in the return values. In the example above a .more-link CSS class is applied and the title attribute has a value applied to it.

To set up differing ‘read more’ text based on if a post belongs to a certain category such as ‘view more’ you would need to use the function surrounded by conditionals – example below

13 Comments

  1. Martin on August 10, 2016 at 9:58 am

    If you use the_excerpt in a filter ( add_filter( ‘the_excerpt’, ‘excerpt_read_more_link’ ); ) it trims of excerpt posts so no text is displayed.
    If I use excerpt_more in a filter ( add_filter( ‘excerpt_more’, ‘uaf_excerpt_more’ ); ) it shows my excerpt post but only diplays excerpt read more link on some posts.
    How do I force read more link in all the posts and still have the read excerpt text appear.

  2. Koen on March 20, 2016 at 9:14 pm

    So awesome, works great!!

  3. Leslie Wiesman on March 2, 2016 at 9:03 am

    Oh my goodness…. I literally love you right now…. thank you!

  4. Bryan on January 11, 2016 at 4:36 pm

    Stellar. This is exactly what I was looking for.

    *Note you can stylize the look of the text in the link further by editing your CSS and changing the attributes – in my case it was the attributes for the “a.more-link”, not sure if that’s what it would be for everyone.

    Extremely helpful!! Thank you!!

  5. kaushik on September 18, 2015 at 5:23 pm

    Wonderful !
    Works for posts that have short text and special content such as video,shortcode recipe etc.

  6. Arvindh on August 17, 2015 at 7:11 am

    Thanks for this! It solved a major problem I was having – earlier, the read more would not work if there was insufficient text in the manual excerpts!

    Now, it works perfectly!

    As a tip for people coming in the future, I used this link to style my link:

    http://www.bestcssbuttongenerator.com/

    Hope it helps!

  7. Maria on July 9, 2015 at 10:40 am

    YEY!!!!!!!!!!
    Lost 1 day trying to fix this, and it worked with your solution.

    thanks a lot :D

  8. Abc on June 19, 2015 at 6:11 am

    Great work. thank you so much. Gbu !

  9. Sue on June 2, 2015 at 8:28 pm

    Thanks, Neil! I tried solutions from other sites but none of them worked. Your code worked perfectly on the Magazine Pro theme.

  10. Beth Hawkes on March 7, 2015 at 2:53 pm

    Thank you, will try

  11. Gina on January 31, 2015 at 8:40 pm

    This worked great but now I need one category archive page to have View Video link instead of Read More link. How do I add that exception to this code?

  12. Matt on November 24, 2014 at 9:10 am

    Yes!!! I’ve been looking for a solution to add a “Read More” button to my custom WordPress post excerpts, and this worked.

    The only change I made with the code was that my current theme has a customized “Read More” button, rather than a plain hyperlink, so I just inspected the element of a non-customized Excerpt to find the code of the custom button, and replaced the above code in my Child Theme’s functions.php file, and voila! It worked!

    So, the code I used was this:

    //Read More Button For Excerpt
    function themeprefix_excerpt_read_more_link( $output ) {
    global $post;
    return $output . ‘ ID ) . ‘” class=”read-more-button”>Read More‘;
    }
    add_filter( ‘the_excerpt’, ‘themeprefix_excerpt_read_more_link’ );

    The only difference is: class=”read-more-button”.

    Soooo happy! Thank you! I’ll just have to use custom excerpts for my future posts, otherwise I’ll get a double “Read More” button.

    You can check out my custom post excerpts and the working “Read More” button on my home page here: http://sworntosucceed.net

    (P.S. I’m using a plugin that disables right-clicks on my website, to avoid plagiarism and my work being copied, so you won’t be able to view the code, but I’ve pasted it here anyway.)

    Thanks again! :)

Leave all Comment