Using the “More” Tag on WordPress Pages

Some of you may notice I’ve recently added a “blog” section to this site in addition to the existing “tutorials” section. Even though I use excerpts for my summaries in the tutorials section, I wanted to use the “more” tag in the blog section to accomplish the standard blog setup with the beginning of a post on the homepage and the rest on the single post page, with a “Read more” link allowing the reader to click through to the latter.

Two Blog Homepages

There’s a small problem with having what essentially amounts to two blog homepages…one for the tutorials section and another for the blog section. The problem is that I have to tell WordPress to use one as the actual blog homepage, which, in my case, I’ve already set up to be the tutorials page. By default, WordPress won’t let you use the “more” tag to clip posts on any pages other than the specified homepage. So, I did a little searching and found a really simple fix for this problem over at Weblog Tools Collection.

The Solution

The solution is incredibly simple, although, if you didn’t do the exact same Google search I did you may have trouble finding it, so here it is.

All you have to do is add the following line just before the code to display your post content:

<?php global $more; $more = FALSE; ?>

So you end up with something like this on the page where you want your posts to be cut off (the “Blog” page in my case):

<?php global $more; $more = FALSE; ?>
<?php the_content('Read more &rarr;'); ?>

Why It Works

I haven’t looked into the specific details on why this works, but it appears that WordPress uses the global variable “$more” as a flag to tell it whether or not the “more” tag should function on a given page. By default it’s probably set for whatever page you specify as your blog’s homepage, but not the rest. The code above sets the global variable “$more” equal to FALSE before displaying the post content so that WordPress respects the “more” tag on that page.

Ignoring the “More” Tag Once Again

Incidentally, you can set $more = TRUE immediately after displaying your content and WordPress will ignore the “more” tag in any posts following that one…like so:

<?php global $more; $more = FALSE; ?>
<?php the_content('Read more &rarr;'); ?>
<?php $more = TRUE; ?>
image_pdfimage_print
34 Comments
  1. brilliant! thanks for this

  2. Holy cow. Thanks so much. I could not figure out how why the more tag wasn’t working on a custom page. You rock man.

  3. And how can I do the same thing for my RSS-Feed? I try to figure it out the whole day, but don’t know how.

  4. Argh — I saw the article you referenced — and copied and pasted both his and then yours… and neither work. The full blog post continues to be displayed — no more link. I am using 2.7.1 — do you think there are any reasons this won’t work? Thanks.

  5. Mmhhh…like Courtney here says, I am using WP2.7.1 also and somehow I do not get the ‘more’ tag to work.

    There finally is a ‘read more’link at the position I want, but when clicking on this link nothing happens.

    I have followed many instructions, besides the one mentioned here, but none of the advice seems to be use full.

    Is this because of WP2.7.1?

    I really would like to know how this works?!

  6. I love you ;-)

  7. Wow! Thank you so much! I’ve been searching all night how to do this and nothing else worked.

    This is absolutely brilliant. I have a similar setup on my blog, a separate page that I’m using more like a personal blog than the main site and didn’t want all of the post on that page.

    When I couldn’t figure out why the ‘more’ tag wasn’t working, I started doing google searches.

  8. For users of 2.7+ that are using this with a custom query in a static page use the examples at:

    http://codex.wordpress.org/Template_Tags/query_posts

    worked for me.

  9. This is not something I had ever come across before, but I am glad someone beat me to it and has a working solution!

    (Love the header picture by the way! haha)

  10. John, thanks so much for this one. I searched high and low trying to figure out why the Evermore plugin wasn’t working with my new theme. Once I tried this, I got it working.

    It seems that the last posts here on the subject are 9 months old. Is there any new information on this?

    Thanks… Dan

    • Nothing really Dan, but WP3.0 is coming out in a month or so and will have several improvements. We’ll see if that changes things at all.

  11. thanks very much this worked and it was exactly what i was looking for. found your page via a good search “wordpress show read more link on pages” lol thank god i found you :D

  12. I cannot change the more tag on my posts page: http://www.thebreadcrumbtrail.org/big-blogs

    I’ve tried editing the content tag in my index.php file to something like , but to no avail. Any ideas?

    Thanks

    James

    • Looks like your comment got filtered. You’ll have to use html entities if you’re posting most html in your comment.

  13. Damn I love you for this :)

    Beeing googling with no success. But this has done the job !

  14. Thanks a million..had to reply to show my appreciation for this!!

  15. Ohhhhhh man !!
    You don’t know how much i love you !! ;)

    No really, i mean it !
    Gosh !

  16. I tried this but it doesn’t quite work. I have the tag on my blog post, I added the right before the call to: like you say in your example.

    On my single post page, I do see a link that says “Read More”, but when I click on it, I am taken to the same page, that looks exactly the same with the same “Read More” link. In other words the link doesn’t take me to the rest of the post, it just takes me to the exact same beginning of the post.

    Also, can you have many read more links in a single post? Thanks!

  17. Worked perfect for me. Thank’s for the quick fix, John!

  18. Thank you so much for this. I just wish I had found your solution sooner. Worked perfectly!!!

  19. Just the answer I was looking for. Was wondering why the read more wouldn’t work on individual category custom templates. Thanks for posting!

  20. Thanks… it works perfect!

  21. Hi,
    for first thank you. But I still have a problem. I added the code you suggest and now the “Read more” appear in my page where I want but if I click on it nothing changes but the URL where the string #more-numberofthepage is added to the permalink. But the content shown is the same.
    Any suggestion to give me?
    Thank you

  22. I have been looking for this fix for about two weeks now for a client, Thank you so much for the informative post and it worked no problem!! You just made my life 10x less stressful as this was one of the final steps of the website that we had to do.

    Thanks again John! I will be linking to this site from my blog, and even use it in a recording!

    - Andrew Kaser

  23. hey Guys,

    Thanks for the post. I was able to add the read more option to one of my pages but now the problem is the”continue reading” link that appears does not show the rest of the blog. It looks like the link just redirects my blog site and adds a #more -37 at the end of it.

    Any thoughts on fix?

  24. Can the php code be used for custom pages in wordpress?

  25. Thanks for the post.

    Can I just clarify. Will this code work on a Page or Post? I have added this to my page template and the code works but when you click in read more… it dose work. I am clearly missing something.

    I have placed about and the read more part works, but when clicked it will not show or open the content/words

    Mike

    • Hey Mike, this post is “Using the ‘More’ Tag on WordPress Pages,” so yes, it’s specific to pages. The more tag works by default on posts.

      • Thanks John. Any why its not working for me? The code works the pages has the (Read more..) link. But when I click on it doesn’t open the rest of the text

  26. How would you ever find something like this out without digging deep into the code?

    Useful little snippet I can add to my snippet archive, read more here I come! Thanks.

Address

Razorlight Media
Phone: 513-549-7355
Fax: 866-377-4331
Url:
cash, check, credit card, invoice, paypal
2207 Kemper Lane
Cincinnati, OH 45206
700 West Pete Rose Way, #68
Cincinnati, OH 45203