Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

CHAPTER 3 • The Loop 49


Remember not to use the_excerpt() on templates displaying just one post, such as single.
php. You need the_content() to display the full content! And, yes, should you want to,
you can use them together.


USING STICKY POSTS


WordPress added something called sticky posts way back in version 2.7. People familiar with
online discussion forums will recognize the lingo; it is basically something that sticks to the
top of the post listing at all times. No matter how many new posts are added, the sticky post
remains the first item at the top of the listing of posts. In the Edit Post screen, you can set a
blog post to sticky, hence making it stay on top at all times on your site (see Figure 3-3). If
two or more posts are sticky, they will all appear at the top of the list, in chronological order.
When you remove the sticky setting from the Edit Post screen, the post will automatically
sort itself into place with the others.


Figure 3-3: A sticky post as displayed by the Twenty Thirteen theme.


There is a sticky_class() template tag to output the sticky post class, but with the
addition of post_class(), it really isn’t very useful:


<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>


The lovely post_class() template tag adds a number of classes to the post, depending on
the details of the post. This is very useful for a designer, so this book covers post_class()
in more depth in Chapter 6, “Advanced Theme Usage.”

Free download pdf