Using the “More” Tag on WordPress Pages

Summary:
If you try to use the "more" tag on any page other than your blog's homepage, you've probably noticed that it doesn't work. In this tutorial, I show you a really simple way to enable the use of the "more" tag on other pages in your WordPress blog.
buzz_button

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; ?>
 
Bookmark and Share

11 Comments so far ↓

  1. chad says:

    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. Mirco says:

    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. Courtney says:

    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. Erick S. says:

    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. Patty Gale says:

    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.

  7. Quasar says:

    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.

  8. GKauten says:

    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)

  9. Dan Cartier says:

    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


Leave a Reply

Email is required but will not be published. All comments are moderated and no-followed. Please do not use keywords or domains as names and do not advertise.