How to set a Read More Link on Blog Archive page

Generally, the excerpt function which allows you to show the first “55” words of your post in the archive pages (categories and tags) and the homepage.

Post Excerptt

So what if you want to show the Read More button for all of the posts. Well to do so you can inject this below code to your theme/child-theme’s functions.php file

//Read More Button For Excerpt on the blog post archive page or homepage
function excerpt_read_more_link( $output ) {
    global $post;
    return $output . ' <a href="' . get_permalink( $post->ID ) . '" class="ReadMore" title="Read More">Read More</a>';
}
add_filter( 'the_excerpt', 'excerpt_read_more_link' );

You can also manipulate the ReadMore class for custom CSS styling.

BONUS

Apart from this, what if you want to show the excerpt words with more than “55” words!

Well, to do that there is two way one is a manual process. Like- edit the associated post and insert your excerpt manually on the excerpt meta-box (like below). Yea, this is a quick solution, isn’t it?

How to set a Read More Link on Blog Archive page 1

But just imagine, you have hundreds or more articles published on your site & you want a quick solution for that. Isn’t it a bummer to edit all of the existing posts to update the excerpt?

Custom function Method

To avoid that such situation, luckily WordPress has a built-in filter named excerpt_length that will allow changing the default length of your excerpts from your theme/child-theme functions.php

/* Increase the default post excerpt length */
add_filter( 'excerpt_length', function($length) {
    return 35;
} );
How to set a Read More Link on Blog Archive page 2

Tie-up

Oh, How lazy I’m! This is all for now. See you soon with another tips.

Cheers!

Default image
MM Aurangajeb
Support Engineer, Blogger. Learning Web Design & Developing, Tech & WordPress Enthusiast, WordPress Lover. Always try to learn new things, new hacks, new techs.

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.