4. Wordpress More Links and Excerpts

There are two ways posts can be shown, the full posts, or an excerpt. In Wordpress Hack #1: query_posts I showed you what to add to “the loop” to make posts excerpts. For your homepage, there is an easier way to do this with the Homepage Excerpts Plugin.

homepage excerpts plugin example options wordpress

This plugin (as you can see in the options above) gives the flexibility to say how many posts will be full and how many excerpted, and how many words to show. You can also choose to use “custom excerpts”, which is a field you can fill out when writing a post. It’s very important you understand how this works. When you create a post there is a field you can write you own “excerpt” into. You probably never noticed it, it’s below where you write your posts, and it looks like this:

excerpt example

If you write a “custom excerpt” in this field, and then use the homepage excerpts plugin and change “use custom excerpts” to “yes” – then the custom excerpt will show instead of the first 50 words from the post. This means that you can have original content on your homepage that’s not on single post pages. You could also use these custom excerpts for other things, like a featured block on your homepage. It’s a lot more work to write one for every post you have, but could be well worth it depending on how you’re using your blog.

Now that you know how to change your homepage to excerpts using a plugin, let’s find out how one hacks code in a theme to do this at will! Once again, you can find this information on the Wordpress Codex page “Customizing the Read More”. On any wordpress theme template page that displays posts in a “10 per page” fashion, like your homepage (index.php), a category or tag page (category.php or tag.php if you have one), or an archive page (archive.php) – each of these pages has a loop containing the call “the_content”. Anytime you see “the_content” in the loop – it’s a PHP call to get “full posts”. In other words, code that looks like this gets full posts:

<div class="entry">
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>

If you want to change that page to show excerpts instead of full posts, just change “the_content” to “the_excerpt” like this:

<div class="entry">
<?php the_excerpt('Read the rest of this entry &raquo;'); ?>
</div>

To learn how to customize the actual “read more” text in the link to the full post, The Read More Codex Page has all the details and sample code you need.

Pages: 1 2 3 4 5 6 7 8 9 10 11

This post has multiple pages...

  1. 10 Ways to Improve Navigation
  2. Page 2 - Adding Breadcrumbs to Wordpress Navigation
  3. Page 3 - How to Hack Ugly Wordpress Next and Previous Links
  4. Page 4 - Wordpress Next and Previous Links for Single Pages
  5. Page 5 - Wordpress More Links and Excerpts
  6. Page 6 - How to Achieve Multi-Paged Post Navigation in Wordpress
  7. Page 7 - How to Add Related Posts After Content in Wordpress
  8. Page 8 - How to Display the Most Viewed Posts in Wordpress
  9. Page 9 - How to Show Most Popular Posts in Wordpress
  10. Page 10 - How to Assign and Show Category Images in Wordpress
  11. Page 11 - Sidebar Navigation Options in Wordpress
  12. View All

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,