Wordpress

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:

1
<?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):

1
2
<?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:

1
2
3
<?php global $more; $more = FALSE; ?>
<?php the_content('Read more &rarr;'); ?>
<?php $more = TRUE; ?>
John Crenshaw
John Crenshaw
President
UFO company founder. 15+ years experience in performance marketing.
Never miss an update
Get more training, case studies and ideas delivered directly to your inbox.
* We never share your personal info.
View our Privacy Policy.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Let’s make something great together
Let’s talk.

Get in touch and we’ll setup a quick call to discuss your needs, what we do, and figure out if we’re a good fit.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.