HowTo – Modifying The WordPress Read More Link

Filed under: Wordpress Tips

When your posts are listed on a index or category page the default setting is to use an excerpt however you can also use the full text of the post which is called the_content.  In either instance more then likely you won’t want to display your entire post if it is over a couple hundred words.

Lucky for you WordPress has a built in feature to display a portion of the page automatically or allow you to set the cutoff point with a <!–more–> comment that you hide in your post when writing it.

By using the more link you can cut off things like large images or galleries or even just table data that may not show up right in your index and category loops.

The standard Content Link

To modify your more link you place the setting in your content call

The generic call for the content is without settings.

[php]<?php the_content() ?>[/php]

Manually Changing the More Link

The easiest way to override the text of the more link on an individual post basis is to modify the more link that you put in your post.  Start with the word more and then add the text that will be displayed.

<– more this is the alternate text–>

You can also remove the teaser from the more link

<!--more--><!--noteaser-->

Modifying All More Tags

There are three perameters that you can set in the_content call.

[php]<?php the_content( $more_link_text , $stripteaser, $more_file ); ?>[/php]

The first parameter controls the text of the more link.

It can be set without setting the other two and by using single quotes to enclose the text.

[php]<?php the_content(‘Read on…’); ?>[/php]

You can also use html and standard quotes to define styles.

[php]<?php the_content(‘<strong id="morelink">Read on…</strong>’); ?>[/php]

You can also use WordPress Calls to grab the Title of the Document.

[php]<?php the_content(‘Read the rest of ‘ .  get_the_title(”, ”, false)); ?>[/php]

Stripping the Teaser from the More Link

The second parameter of the more link is set by using Boolean True or False.

The setting is a little strange though you are setting whether it should be stripped or not … you are not setting whether it should be displayed

So, you use True to strip the teaser

[php]<?php the_content(‘Read on…’, True, ‘ ‘  ); ?>[/php]

Changing the More Link URL

The final parameter lets you change the link a reader will be taken to

[php]<?php the_content(‘ ‘,’ ‘,’$url’,); ?>[/php]

The url should be changed programmatically.

Final Note

You may notice that some themes set the way the more link displays in the functions.php file or through extended coding.

This is more of a rewrite then modification and can provide some unique functions.