• Resolved susafri

    (@susafri)


    I have seen other questions regarding this but none solve my problem:
    I want to show excerpts only on my blog archive page.
    These steps I have done:
    1. I created a childtheme for twentytwelve
    2. I have created a page for home and a page for Blog and set the homepage to Home and the posts page to Blog (reading settings)
    3. I have duplicated the content.php in my childtheme and changed the line
    <?php if ( is_search() ) : ?><div class="entry-summary"><?php the_excerpt(); ?></div>
    to
    <?php if ( is_search() || is_archive() ) : ?><div class="entry-summary"><?php the_excerpt(); ?></div>

    But the blog page shows a list of full blog posts, not excerpts. What am I doing wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try using

    <?php if ( is_search() || is_home() || is_archive() ) : ?>

    Right now your saying, if it’s search or archive. The blog isn’t an archive.

    I’m not sure if is_home() will work, but it might. I know it would if your homepage is the blog.

    Looking at the content.php of 2012 a bit more closely, I can see this on line 33:

    <?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; ?>

    Try getting rid of the if else entirely to just this:

    <div class="entry-content">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-content -->
    Thread Starter susafri

    (@susafri)

    Hi Christine. Your first solution worked! Thanks so much! I thought for sure the blog page is an archive.
    I have tried your second suggestion before, but that makes everything, even pages, show excerpts.Very strange. My homepage is a static page, not a blog.

    Christine

    I tried your suggestion of including just

    <div class="entry-content">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-content -->

    But when I click the title to go read the full article, it’s just the excerpt again :-/

    Actually, I found the issue. Change a single line:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>

    to:

    <?php if ( is_search() || is_home() ) : // Only display Excerpts for Search and Index ?>

    Now, whatever page you have set your Posts to be on will only show excerpts, but clicking the header links will display the entire post.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘show excerpts on twentytwelve childtheme blog page’ is closed to new replies.