How to display excerpt in WordPress? Customizing the "Read More" tag

Over the course of time, I’ve been receiving lots of queries, “how I’m displaying, “random, latest, previous posts”, and “excerpts”. I’ve responded those queries many times, so I thought to explain each queries on a seperate blog post to help the users. In this post, I’m going to explain “More Tag”. As you can see, I’m using […]

Over the course of time, I’ve been receiving lots of queries, “how I’m displaying, “random, latest, previous posts”, and “excerpts”. I’ve responded those queries many times, so I thought to explain each queries on a seperate blog post to help the users.

In this post, I’m going to explain “More Tag”. As you can see, I’m using excerpts on my index / archive page, and full contents are displayed on single page only. To get the excerpt on my index /archive pages, I’m using a plugin for the past 3+ years, called “Excerpt Reloaded”.

If you don’t want to use seperate plugin for excerpts, you can use the_content function with <!--more--> tag at the point, which you want to prompt readers to click on a link to “read more,” or simply use the_excerpt funtion. But there’s a problem with this function, when you click on the “read more” link, the web page loads and then “jumps” to the section, where the <!--more--> tag is placed in the post. If you do not want “jump”, you can change the default functionality of how this function works by editing the following line in wp-includes/post-template.php:

Open your file and search for the following code:

$output .= ' &lt;a href="'. get_permalink() . "#more-$id\"&gt;$more_link_text&lt;/a&gt;";

….change to:

$output .= ' &lt;a href="'. get_permalink()<br />."\"&gt;$more_link_text&lt;/a&gt;";

Note: If you follow above steps, you’ll have to do this manual adjustment, every time you upgrade WordPress. On a safe bet, it’s advisable to use Excerpt Reloaded plugin, which offers many customization.