0

I followed the excepted answer to this question (Twenty Eleven home page show only excerpt) to a tee. And it worked just like I hoped for the main page. But now when I click on the blog post and go to the post's page, it also only has the excerpt.

How can I make this change so that the excerpt shows only on the main page, but the full blog article on the actual post's page?

My blog is located at http://sqlsalt.com for reference.

1 Answer 1

3

I am guessing a bit but based on your description, you probably only have an index.php file running both of those pages. If you create a single.php file in the theme that (probably) matches what you had in the index.php before you edited it, you should have what you want.

WordPress will look in the theme for files of particular names to display content. Ultimately, if no specialized files are found, index.php will be used to display most everything. I think that is what happening in your case.

Another approach

Edit content.php and change the call to the_excerpt to

if (is_singular()) {
  the_content(); // there may be parameters in your existing code
} else {
  the_excerpt(); // there may be parameters in your existing code
}

Unless you have something like content-single.php in which case you will need to look in that file but it sounds like the same content.php is being used.

4
  • 1
    So basically go to the theme's directory (wp-content) and create a single.php file, copy the contents from index.php, and then just modify that one div's class? Commented Mar 24, 2013 at 15:36
  • It isn't the class that matters. It is changing the_content to the_excerpt. You want the_content to get the full post display. That is even noted as the significant change in the accepted answer to the original question.
    – s_ha_dum
    Commented Mar 24, 2013 at 15:39
  • But that call is in the content.php file. Are you saying to still have that change there? I would have thought I wouldn't want to make that change in content.php. Just use the entry-summary class for index.php and entry-content for single.php...? I must be missing something if that isn't correct. Commented Mar 24, 2013 at 15:55
  • Changing the class name won't help you. The class name has nothing to do with what PHP outputs. the_excerpt and the_content output different things. See the edit.
    – s_ha_dum
    Commented Mar 24, 2013 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.