0

How do I enable excerpts in the theme?Currently excerpts are only displayed on the search page but I would like to enable them on tag and category pages.

  • Made an update with my answer. If that helped your cause, don't forget to mark it as an accepted answer. ;) – Mayeenul Islam Dec 10 '13 at 1:31
1

In TwentyThirteen, there are many files, their names're started with content:

  1. content.php
  2. content-none.php
  3. content-aside.php
  4. content-audio.php
  5. content-chat.php
  6. content-gallery.php
  7. content-image.php
  8. content-link.php
  9. content-quote.php
  10. content-status.php
  11. content-video.php

Among them, except the first two, all the others are for different post types, and you can understand their usages from their names.

The 2nd one, content-none.php is used to display apology texts, when there is no content found with a query. And the 1st one, content.php is used in various display pages with two conditions, where:

  • is_search() — is to check whether it is the search result page
  • is_single() — is to check whether it is the post details page

If you open the index.php, you will find a code:

<?php get_template_part( 'content', get_post_format() ); ?>

Here the template part (content.php) is called.

Answer

So, to show excerpt in your front page or home page, you will need to modify content.php. Like the is_search(), is_single(), there are several other checkers in WordPress:

  • is_home() — is to check whether it is the home page
  • is_front_page() — is to check whether it is the front-page
  • is_category() — is to check whether it is the category archive page
  • is_archive() — is to check whether it is the general archive page
  • is_tag() — is to check whether it is the tags archive page
  • ...so on

And you may know that, to enable excerpt instead of full content, you will have to change the code the_content() to the_excerpt().

More Details

EDIT

Yep, @Rarst said a very important thing that, if you make change into any public theme, the changes will be wiped out when a new update will take place. So, to put your modifications in place, you have to make a Child Theme on TwentyThirteen. A Child Theme is nothing but a new folder with a stylesheet. You can get that at:

  • 1
    While explanation is sound the better action to take would be creating child theme with the changes, otherwise 2013 updates will wipe changes out. – Rarst Dec 9 '13 at 16:51
  • @Rarst Thank you for reminding such an important issue. Edited the answer with your suggestion. – Mayeenul Islam Dec 10 '13 at 1:30
  • You are free to accept the answer. Just click on the check mark on the left to any answer. :) – Mayeenul Islam Dec 10 '13 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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