Support » Fixing WordPress » How to add an excerpt

  • Site:
    Theme: Child-Twentytwelve

    Recently want to turn my posts into excerpts, and tried doing this by writing in the excerpt box on the ‘edit post’ screen in dashboard. However, it seems this is not possible until I replace <?php the_content; ?> with <?php the_excerpt; ?> which according to various web sources, is located in the theme’s index.php file. However, I couldn’t find this in mine, but found it in the content.php file after finding this:
    So…after copying the file into my child theme, I commented out the <?php the_content; ?> and replaced it with <?php the_excerpt; ?>. After saving, I loaded the page to find that my page is still showing the full post and no excerpt…anybody know what I am doing wrong?

    Thanks for your time!

Viewing 3 replies - 1 through 3 (of 3 total)
  • unfortunately, you haven’t posted your edited code;

    this is the section in content.php of Twenty Twelve:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    		<?php else : ?>
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    		<?php endif; ?>

    this is the line that would need chnaging:

    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>

    alternatively, you could make the changes by edting the conditional statement; from:
    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <?php if ( is_search() || is_home() || is_archive() ) : // Only display Excerpts for Search, Posts Page, Archives ?>

    make sure to save the file after the changes;
    make sure to edit the copy of content.php in your child theme …

    Twentytwelve has many different post formats. All the template files that start with content- are used to display posts of different formats.

    You don’t need to change any code to use excerpts with Twentytwelve though. Just insert <!--more--> in the page where you want the page to break in two parts and only the part before that code will be displayed in the blog.

    The directions that you suggestion are exactly what I tried that did not work, with the exception of the alternative technique which I will try soon. Also, maybe It would make a difference that I was trying to make these changes on my localhost with WAMP server? I don’t know why it would be this though, since everything seems to be running fine (pages and links work)

    I was considering using the <!–more–> tag, but don’t want to do this with every single post, so that is why I am trying to edit the code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add an excerpt’ is closed to new replies.