I’m wondering what should be used in index.php (post listing page): the_excerpt() or the_content()?

  1. Twenty Thirteen uses the_content() but this prints entire content unless <!--more--> exists and it completely ignores Excerpt field from [Posts > Add New > Excerpt].
  2. So, I used the_excerpt() instead but this doesn’t react to <!--more--> tag at all and it just grabs first 55 words or uses manual Excerpt and doesn’t produce “Read more…” link.

What I would like to achieve is this:

  • print 55 words
  • but react to <--more-->
  • and if manual excerpt is specified, use this instead (most people don’t want the beginning of their post to be their excerpt so this is of crucial importance)
  • produce optional “Read more…” link

This looks like the most intuitive to me for post listing pages. Does something like this exist?

If not, should the_content() be used on post listing pages? I think that most theme users aren’t familiar with <--more--> tag and they rather expect that themes will create proper excerpts for post listing pages rather than displaying full post content.

Reference:

  • http://codex.wordpress.org/Function_Reference/the_excerpt
  • http://codex.wordpress.org/Excerpt
  • ​http://www.rarst.net/script/wordpress-excerpt-teaser/

1 Answer
1

Your requirements slant towards using the_excerpt() with adding read more link by custom code:

  • print 55 words – already this by default and adjustable via excerpt_length filter

  • but react to <!--more--> – this already happens, auto-generated excerpt cannot be longer than teaser (part from start of post to <!--more--> tag)

  • and if manual excerpt is specified, use this instead – already works like this

  • produce optional “Read more…” link this is one thing excerpt doesn’t do natively. Can be added via:

    • excerpt_more filter, note it is only used if post was cut
    • get_the_excerpt or the_excerpt to append to any excerpt
    • in template, separately for excerpt template tag call

Leave a Reply

Your email address will not be published. Required fields are marked *