Showing Part of a Post

At the heart of every WordPress blog is a home page, and at the heart of every
home page is a reverse-chronological list of posts. This list serves a vital purpose,
showing a snapshot of current content so readers can tell, at a glance, what’s going
down on your site.
However, the home pages you’ve seen so far have had one potential problem—they’re
long, sometimes awkwardly so. Having multiple posts fused together into one long
page is a great convenience for new visitors who want to read your content from
end to end, but it’s not so helpful for return visitors who want to survey your new
content and decide where to dive in.
Fortunately, WordPress has a handy solution. You can decide to show only the first
part of each post, called a teaser, on your home page, which your visitor can click
to read the standalone post.

One advantage to this approach is that you can pack quite a few teasers into your
home page and keep them close together, no matter how long the posts really are.
You can also put posts into tighter layouts—for example, creating a site that looks
more like the front page of a newspaper. Another advantage is that it encourages
readers to click through to the post, where they’ll also see the post comments and
get the opportunity to join in the discussion.

However, trimming down posts introduces two possible disadvantages. First, there’s
the extra link readers need to follow to read a full post. If someone wants to read
several posts in a row, this extra step can add up to a lot more clicking. Second, you
need to explicitly tell WordPress what part of a post belongs on the home page. It’s
an easy job, but you need to do it for each post you create. If you’ve already written
a few posts, you need to update them.

NOTE As a general rule, informal, conversational blogs work well with the standard one-post-after-another
stream that WordPress displays on the home page. But WordPress sites that have more detailed article-like posts,
use multiple sections, or feature multiple authors, often work better with a tighter, leaner style that uses teasers.

 

Displaying Teasers Using the “More” Quicktag

The best way to cut a post down to size is with a special WordPress code called the
More quicktag. You place the More quicktag at the spot where you want to divide
a post. The content that falls before the tag becomes the teaser, which WordPress
displays on the home page (Figure 6-17, left). If a reader clicks through to the post
page, he sees the entire post.

To insert the More quicktag in the visual editor, go to the spot in your post where
you want to put the tag, and then click the Insert Read More Tag button. You’ll see
a light-gray dividing line (Figure 6-18).
You can also add the More quicktag in the HTML editor. You could click the button
labeled “more,” but it’s just as easy to type in the tag yourself, wherever you want it:

<!–more—>

HTML nerds will recognize that the More quicktag looks exactly like an HTML comment—
the sort of thing you might put in your markup to leave notes to yourself.

Browsers ignore HTML comments, and WordPress borrows this system to sneak in
some of its own special codes.

NOTE WordPress uses the More quicktag whenever your site displays more than one post at a time. The
home page is the most obvious example, but you’ll also see multiple posts when you browse by category, date,
or keyword. In these situations, the More quicktag serves the same purpose—it trims long posts down to more
manageable teasers.

There’s one more trick you can do with the More tag. In the previous example, a
“Continue reading” link led from the teaser to the full post. The theme determines
the link’s wording, but you can substitute your own text. To do that, you need to
edit your post in HTML view, and then stick the link text in the middle of the More
tag, exactly as shown here:

<!–more Tell me more—>

If you want to change the link text for every teaser, editing your theme is far more
efficient than editing individual posts (see Part 4 to learn how to edit your theme).

 

Dividing a Post into Multiple Pages

The More quicktag lets you split a post into two pieces: the teaser, and the rest of
the content. Alternatively, you can split a page into as many sections as you want
using the lesser-known Nextpage quicktag. When you do, WordPress adds a set of
navigation links to the bottom of the post

To insert the Nextpage quicktag, switch to the HTML view (click the Text tab) and
then add this code where you want to start a new page:

<!–nextpage—>

The Nextpage quicktag shows up in the visual editor, as a gray line with the words
“Next Page” above it. You can’t customize the Nextpage quicktag, but you can create
custom page links if you’re willing to edit your theme files, as described in Part
4. The trick is to master WordPress’s wp_link_pages() function, which is described
at http://tinyurl.com/wplinkpages.
You can use the More and Nextpage quicktags in the same post. However, it’s generally
a bad idea, because the page-navigation links will appear under the post teaser on
the home page. This is likely to strike your readers as plain odd or utterly confusing.

Summarizing Posts with Excerpts

There’s another way to shorten posts on the home page: by using WordPress’s excerpts
feature. Ordinarily, an excerpt is the first 50 or so words in a post (the exact
number depends on the theme).
Before you can really understand excerpts, you need to know how WordPress uses
them. The answer isn’t straightforward, because it depends on your theme. Some
older themes may avoid excerpts altogether, while others use them prominently
(as you’ll see shortly). But most themes use excerpts in at least one place: on the
search results page. To take a look for yourself, type something into the search box
and then press Enter.

So far, excerpts seem straightforward and automatic (and they are). However, the
first few sentences of a post aren’t always a good reflection of its content. For that
reason, you may want to write your own excerpt—in other words, explicitly provide
a brief summary of the content in a post. You can do that from the Add New Post
or Edit Post pages. First, choose Screen Options in the upper-right corner, and then
turn on the checkbox next to Excerpt. A new box appears where you can write a
custom description of your post.

NOTE Things can get a bit confusing if you use excerpts and teasers. In that case, WordPress uses an excerpt
if the post has one, a teaser if the post uses the More quicktag, or the first 55 words in the post if it has neither
an excerpt nor a teaser.

Advertisements
Showing Part of a Post

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s