WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] show excerpts on twentytwelve childtheme blog page (6 posts)

  1. susafri
    Member
    Posted 1 year ago #

    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?

  2. 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.

  3. 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 -->
  4. susafri
    Member
    Posted 1 year ago #

    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.

  5. jparnell8839
    Member
    Posted 1 year ago #

    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 :-/

  6. jparnell8839
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic