- WordPress has a key feature that has seen less and less use today, but that I think is not only important, but essential. The ability to truncate content and create custom excerpts for index pages. In most WordPress themes, 2015 included, if you write a long post and do nothing that post will appear in its entirety on the blog index and other index pages. If you have many blog posts all of these posts will be loaded in their entirety in the index pages and in WordPress the default number of posts in an index page is 10.
This not only produces the annoying necessity to scroll past entire posts to get to the next one, which is amplified when people use mobile devices to access your site, but it makes index pages much larger, which results in longer load times. You can imagine if you have 10 posts and each post has a lot of images and you have to load them all on an index page it takes up a lot of time and a lot of bandwidth to do so. To combat this WordPress gives you the ability to truncate your posts for display on index pages in two ways. Either select the point in your post where you want a read more link to appear, as we've seen earlier, or create a custom excerpt to be displayed.
Let's look at each of them in turn. First I want to truncate my post, so I'll go to my post on the front end, then click Edit Post in the WordPress toolbar to get to the editor, and then find where in my post I want the truncation to appear. Now I've shown you this feature before, but it's worth repeating so you can see what happens on the front end. Here I want the post to truncate after the first block quote here, so I'll place my cursor after the block quote, hit return twice to exit the block quote, and then I'll click Insert Read More tag button from the content editor toolbar.
This adds this graphic here. I can now go and update my post and you'll see if I go to View my Post nothing has changed. Here's the full post in the single post view and everything is normal. However, if I go to the front page of my site you'll see my post has now been truncated. We have the first paragraph, we have the block quote, and then we have a link that says Continue reading. If I follow the Continue reading link I'm taken directly to the next section within my article. So here we have 5K to H+ and then my next paragraph.
So we're skipping past the content that we assume the reader has already read on the front page. This truncation has many advantages. As you can see it becomes much easier to scroll through all the content and if your theme, like 2015, displays all the meta information at the bottom of the post it's much easier to get to, you don't have to scroll past tons of text to get to all this information. You'll also see that if I jump to the category index, the tag index, or even the date or author index we always see this truncated version of the post, unless this is the only post that exists in that particular index.
But I also mentioned that there's another way of truncating your post using excerpts. And to show you how this works I first have to give you an example. So if I go to my site and I go to Search and I search for sport I will get an index of all of the posts that have the word sport either in the title or the content. But unlike the other indexes this index shows the post title, followed by an automatic excerpt that grabs a certain number of letters from the top of my content and displays that. And as you can see what it's done here is just grab the two first paragraphs.
All the styling is gone, the links are gone, and we are only seeing the excerpt. Now this is entirely theme dependent. Different themes will handle excerpts differently. And different themes will display excerpts in different places. Some themes display only excerpts at every single index page, other will only display excerpts if they are custom excerpts, and some will only display excerpts in certain locations, like in 2015 we only see them in the search results. The problem with this excerpt, as you can see, is that it just takes the beginning of my post and just pastes it up.
So if my post started with a bunch of images you would just see the URLs to the images and that would make absolutely no sense to anyone visiting. So instead we want to control the excerpt. To do that I need to go back to my post and edit the post, then I have to go up to Screen Options, and trigger the field called Excerpt. Once that's opened I can scroll past my content editor and I have a new field here called Excerpt where I can place my new custom excerpt. Now this excerpt serves two purposes.
First of all it'll show up any time the theme asks for an excerpt, so that means now that I update this post and jump back to my search results we are now seeing that new custom excerpt instead of the automatic excerpt that was created previously. But the second benefit is the more important one. When you create a custom excerpt like this and you use one of several SEO plugins it's that excerpt that gets shared on social media sites when people share your content. That way you can control what people see, so they don't just see the beginning of your post, but they see a customized short message that explains what that post is about.
And that's why I like to use this Excerpt field even when my theme does not support excerpts. So now that you know how truncation through the more tag and excerpts work next time you change to a new theme I want you to test these features and figure out how they work in the particular theme you're using. And keep in mind that excerpts may appear in odd places, like only the search index, or only the category index, or somewhere else.
Note: This course covers an older version of WordPress, which features the Classic Editor. Watch this course only if you are using the Classic Editor plugin or using WordPress 4.9 or earlier. Otherwise, watch WordPress 5 Essential Training, which covers the new Block Editor experience.
- Creating posts and pages
- Formatting text
- Publishing and scheduling posts
- Adding images, audio, and video
- Bulk editing posts and pages
- Customizing themes and menus
- Using widgets
- Extending WordPress with plugins
- Editing users profiles
- Configuring settings
- Getting new readers
- Keeping WordPress up to date and secure