WordPress the_content() Selectively displaying or hiding “Read More”

Per the wordpress codex, I was able to remove the “Read More” link on my home page’s post list by using

<?php the_content('',TRUE,''); ?>

Most of our posts link to external articles and thus are maybe only a sentence or two (no need to Read More as it were). If, however, we do write a longer post, I may want that “Read More” to appear. I can choose what is in the excerpt and the rest of the content by using <!--more--> when writing a post. To get a custom “Read More” link, I add

Read More
<?php the_content('Read More',TRUE,''); ?>

But when I do this, “Read More” always appears. Is there a way to selectively show this only if there is content below a <!--more--> comment in the post?

Related posts

1 comment

  1. You can use get_extended() . It returns an array with two keys main and extended. You can check whether the extended key contains anything and display the “read more” link if it does.

    Note that you must pass the post’s content as an argument when calling the function.

Comments are closed.