Creating a Sticky Post

As you know, WordPress orders posts by date on the home page, with the most
recent post occupying the top spot. But you might create an important post that
you want to feature at the top of the list, regardless of its date. For example, you
might write up a bulletin that announces that your business is temporarily closing for renovations, or answers frequently asked questions (“No, there are no more seatings  available for this Sunday’s Lobster Fest”). To keep your post at the top of the list so it can catch your readers’ eyes, you need to turn it into a sticky post.

WordPress displays all your sticky posts before all your normal posts. If you have more than one sticky post, it lists the most recent one first.
You can designate a post as sticky when you first write it (on the Add New Post page)
or when you edit it later (on the Edit Post page). Either way, you use the Publish
box. Next to the label “Visibility: Public,” click Edit. A few more options will drop
into view (including the private post options you’ll explore on page 395). To make
your post sticky, turn on the checkbox next to “Stick this post to the front page,”
and then click Publish or Update to confirm your changes.
The only caveat with sticky posts is that they stay sticky forever—or until you “unstick”
them. The quickest way to do that is to choose Posts→All Posts, find the sticky post
in the list, and then click the Quick Edit link underneath it. Turn off the “Make this
post sticky” checkbox and then click Update.

Advertisements
Creating a Sticky Post

Post Formats

As you learned in Chapter 5, your choice of theme determines the basic appearance
of every post on your site. Once you pick a theme, you can relax knowing that all
your posts get the same font, color scheme, and spacing. Consistency reigns.
But some themes offer an underused feature called post formats, which display different
types of posts in different ways. On paper, post formats sound pretty nifty.
The idea is that you pick a format for each type of post you write, and your theme
uses slightly different styling for each of those post types.
The problem is that WordPress limits themes to a small set of officially sanctioned
formats. They’re mainly useful if you want to create a casual blog (sometimes called
a microblog), where you throw together pictures, video clips, and post fragments,
without worrying too much about organizing your content. In this scenario, post
formats provide a structure that can help tame the chaos of your posts. But if you
want to create your own post format to distinguish a group of posts that are particularly
important to your site, you’re out of luck.
NOTE Ambitious WordPress developers often complain that post formats don’t let them do what they really
want to do: create their own post groupings and apply different formatting to each group. For example, you
might want to take posts in a certain category and alter their formatting to make them stand out. (Imagine, for
example, a news site that uses a bolder background to highlight violent crimes.) This technique is possible—and
useful—but it’s not easy. You need to do all the work yourself, by adding style rules and code to your theme.
(You can find an example starting on page 495.) And you need to have a self-hosted site to use this technique,
because WordPress.com doesn’t allow theme editing.

Understanding Microblogs

Microblogs focus on small bits of content: news headlines, interesting
links, personal status updates, random thoughts, and
stream-of-consciousness chatter. They tend to be less formal,
more personal, and more conversational than posts—almost
like a cross between traditional blogs and old-school messaging
systems like email and chat. Microblogs also mix different
types of content, like audio, video, and images. In fact, some
microblogs are built entirely out of pictures or video clips.
The kings of microblogging are Twitter and Tumblr, but
WordPress fans can join in, too. However, WordPress’s vaunted
flexibility might overcomplicate your efforts. Because Word-
Press allows short, microblog-style posts and longer, more
traditional entries, it’s easy to drown out the small stuff. You
may also find that WordPress’s other features—categories,
tags, the media library, and so on—overcomplicate your
microblogging efforts.

Applying a Post Format

If your theme supports post formats, you’ll see a Format box in the Add New Post
and Edit Post pages. There, you’ll find a list of all the formats you can use with the
theme. You can pick any of them for a post, but if you don’t make a choice, your
post sticks with Standard.

You see these formats at work in the year themes (page 132), from Twenty Eleven
on. Each theme has its own way of styling the formats. Often, you’ll be hard-pressed
to spot the minor changes between an ordinary post and one with a format applied.
In many cases, the only difference you’ll notice is the lack of a title for many formats
(like asides and status updates) and the addition of a small icon. The Twenty Thirteen
theme applies the most dramatic post format styles, with background colors

To get a better sense of what your theme’s post formats look like, create some test
posts and look at them on the home page.

The Ephemera Widget

Some themes include a specialized widget to work with post formats. The most
common example is the ephemera widget. Twenty Eleven and Twenty Fourteen both
include one, named Twenty Eleven Ephemera and Twenty Fourteen Ephemera. The
other year themes don’t include the ephemera widget at all.
As the name suggests, the ephemera widget is all about fleeting scraps of content
that are useful for a short period of time, like asides, quotes, and status updates. The
ephemera widget gathers these bits of microblog content and displays them in a
small, self-contained strip that you can pop into a sidebar (Figure 6-23). The idea is
to call attention to smaller scraps of information that might otherwise be swallowed
up in the clutter of your blog.

TIP You can add more than one ephemera widget if you want to show different post formats. For example,
one widget could show a list of links, a second could list status updates, and a third could show your most recent
asides.
All in all, the ephemera widget offers an interesting way to extract bits of content
from a loosely structured blog. However, most serious bloggers are better served
by using Twitter for microblogging and integrating a Twitter feed into their sidebars,
as described on page 430.

Post Formats

Changing from Full-Post Displays to Summaries

If you create a self-hosted site, you can make any theme display
excerpts or full posts. But, first, you need to learn the basics of
WordPress theme files and the WordPress loop.
Once you know your way around a WordPress theme and the
PHP code inside, you’re ready to make this relatively straightforward
edit. Usually, you need to edit your index.php file,
which creates the post listing on the home page of your site.
To get the display style you want, your code needs to use
the right WordPress function. If you use a function named
the_content(), your page will show the full content of each
post (or the teaser, if you use the More quicktag described on
page 196). But if you use a function named the_excerpt(),
your home page displays the post summary only. Usually, you
can switch between the two display modes by modifying the
line of code that has the function in it.
If you want a bit more technical information, check out the
WordPress function reference at http://tinyurl.com/theexcerpt.

Changing from Full-Post Displays to Summaries

Using Excerpts on Your Home Page

At this point, you might think that it’s not worth the trouble to write excerpts for
all your posts. And you could be right, if you use a standard theme and you don’t
think that your visitors are going to be searching for posts. However, there’s another
factor to consider: Some themes use excerpts for other purposes.
For example, many themes use excerpts as the display text for posts on the home
page. This way, the excerpt acts a bit like a teaser. The difference is that the standard
WordPress teaser comes from the first part of a post, but you control the wording
in an excerpt.
The Brightpage theme described earlier (page 192) uses this system. If you provide
an excerpt for a post, that’s what shows up on your home page, not the post content.
The Oxygen theme, available for both WordPress.com and self-hosted sites, does
the same thing, as you can see in Figure 6-21.

NOTE None of the year themes like Twenty Twelve make much use of the excerpts feature. They use them
in searches (as shown in Figure 6-20), but not on the home page.
If you switch to a theme that makes heavy use of excerpts, you might find the summary
so valuable that you want all your posts to use them, even the ones you’ve
already created. WordPress has some plug-ins that can help. For example, the Excerpt
Editor (http://tinyurl.com/csudedx) can give you a summary for every existing post,
without you having to edit each one individually.

Using Excerpts on Your Home Page

Writing Good Excerpts

The best thing about excerpts is that they don’t need to be
directly linked to the text in your post. But don’t abuse your
freedom—to write a good, genuinely useful excerpt, you need
to follow a few rules:
• Keep it brief. Usually, when a visitor searches your site,
WordPress finds several matching posts. By keeping
your excerpts short (around the 55-word mark, just like
WordPress does), you keep the search results short, which
makes them easier to read.
• Summarize the content of the page. The goal of an excerpt
is to give someone enough information to decide if she
wants to click a link to read the full post. An excerpt isn’t
a place to promote yourself or make flowery comments.
Instead, try to clearly and honestly describe what’s in
the post.
• Don’t repeat the post title. If you want to make sure every
word counts, don’t waste time repeating what’s clearly
visible in the title.

Writing Good Excerpts

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.

Showing Part of a Post

Attaching Other Files to Your Post

Pictures aren’t the only type of file you can put in a post. Word-
Press.com lets you embed a number of other types of document,
including PDFs, Word documents, Excel spreadsheets,
and PowerPoint presentations. In a self-hosted site, you face
no restrictions, so you can upload any type of file you want.
The difference is what happens after you upload the file. Unlike
a picture, you won’t see the content from other types of
documents in your post. Instead, WordPress adds an ordinary
link that points to the uploaded file. If a reader clicks the link,
the browser may display the document or offer to download
it—what it does depends on whether the browser has an add-in
that can display that type of file. For example, many browsers
have add-ins that display PDF documents.

Attaching Other Files to Your Post