WordPress.org

Forums

Twenty Fourteen
[resolved] Display only excerpts on home page/category pages/search results? (17 posts)

  1. FirstTracks
    Member
    Posted 1 year ago #

    Folks, I'm looking for some help in changing the template to only show the excerpt on the stated pages instead of the full article.

    Thanks!

  2. FirstTracks
    Member
    Posted 1 year ago #

    Nevermind, I just answered my own question. For those who may be wishing to do the same, in content.php replace:

    <?php if ( is_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>', 'twentyfourteen' ) );
    			wp_link_pages( array(
    				'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
    				'after'       => '</div>',
    				'link_before' => '<span>',
    				'link_after'  => '</span>',
    			) );
    		?>
    	</div><!-- .entry-content -->
    	<?php endif; ?>

    with:

    <?php if ( is_single() ) : // Only display full content for Single page ?>
    	<div class="entry-content">
    		<?php
    			the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
    			wp_link_pages( array(
    				'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
    				'after'       => '</div>',
    				'link_before' => '<span>',
    				'link_after'  => '</span>',
    			) );
    		?>
    	</div><!-- .entry-content -->
    	<?php else : ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    	<?php endif; ?>
  3. WPyogi
    Forum Moderator
    Posted 1 year ago #

    Note that this kind of change should only be done in a child theme - otherwise the changes will be overwritten upon updating WP

    http://codex.wordpress.org/Child_Themes

  4. Zulfikar Nore
    Member
    Posted 1 year ago #

    A simpler solution is to copy content.php to your child theme and change line 47 from
    <?php if ( is_search() ) : ?>
    to
    <?php if ( is_search() || is_home() ) : ?>

    Less code to add and much cleaner :)

  5. FirstTracks
    Member
    Posted 1 year ago #

    WPYogi: Of course. I made my changes in a child theme.

    Zulfikar Nore: I like the idea of smaller code of course, especially because I really don't know what I'm doing. The problem with your solution, however, is that if I look at indexes of a specific category I'm still seeing the whole post. With my solution I'm only seeing the excerpt on the category index.

    However if you have a smaller solution that does this, too, I'm all ears!

  6. Ayman
    Member
    Posted 1 year ago #

    @FirstTracks, if you wanna apply the solution that @Zulfikar Nore gave you with category archive page than you will have to add the corresponding conditional tag.
    <?php is_category(); ?>
    you can ready more about available conditional tags here:
    http://codex.wordpress.org/Conditional_Tags

  7. Zulfikar Nore
    Member
    Posted 1 year ago #

    In that case the code you'd use is
    <?php if ( is_search() || is_home() || is_archive() ) : ?>

    Zulf

  8. ayeronnie
    Member
    Posted 1 year ago #

    Trying to figure out what I am doing wrong. I did a child theme with all the suggestions in this thread. My posts are now excepts on the home page like I wanted, but there are no titles or anything else, just except text.

    What did I do wrong, or forget?

    Thank you in advance :)

  9. Zulfikar Nore
    Member
    Posted 1 year ago #

    @ayeronnie,

    It would be much better and quicker to get a response if you open a new thread as this one is already marked as resolved - that's in addition to following forum rules :)

    Just reference this thread and give as much details as you can and we'll be glad to help as much as we can.

  10. apuley
    Member
    Posted 1 year ago #

    @Zulfikar Nore: Thank you so much for the information to add to the child theme. Brilliant and works like a charm!

    A simpler solution is to copy content.php to your child theme and change line 47 from
    <?php if ( is_search() ) : ?>
    to
    <?php if ( is_search() || is_home() ) : ?>
    
    Less code to add and much cleaner :)
  11. betholsoncreative
    Member
    Posted 1 year ago #

    Just a quick secondary option if someone is looking for how to do this but doesn't really know code that well. There is a cool free plugin called Fourteen Extended that adds extended options to the 2014 theme's Customize panel in the dashboard.

    One of the many options is to 'turn on' summary/excerpts for blog posts. Works great and there are tons of other options. I use it just because it saves so much time vs. going in and changing the code myself.

    Hope that helps someone!

  12. Y0mst3r
    Member
    Posted 1 year ago #

    How can I add a line of Google+ to the home page of my site

  13. poddys
    Member
    Posted 1 year ago #

    @Zulfikar Nore I was just looking for the same thing, an easy way to just show extracts on the archive pages. Just installed Fourteen Extended, lots of options to explore and it seems to work really nicely. Great job on this.

  14. 徐 仲威
    Member
    Posted 1 year ago #

    @Zulfikar Nore, Genius!

  15. Hannes Salen
    Member
    Posted 1 year ago #

    In the search results of my website, only the excerpts are shown, but I want the post to look like in the category view, so with the continue reading button. Anybody has an idea what I have to change in the content.php?
    I already started a sepperate thread but I got no reactions so far ...

  16. xlightwaverx
    Member
    Posted 1 year ago #

    Though Fourteen Extended is a viable solution to get the Excerpt to show instead of the whole post, as of WordPress 3.9, it fails with WP-CLI with this error:

    PHP Fatal error: Call to undefined function wp_is_mobile() in /home/sitename.com/wp-content/plugins/fourteen-extended/inc/fourteenxt-customizer.php on line 633

    Deactivating Fourteen Extended allows WP-CLI to work again.

    Just letting you know so you don't bork your sites after the 3.9 upgrade.

  17. TheFreeWindows
    Member
    Posted 11 months ago #

    Check the Auto Limit Posts plugin. It cuts down posts automatically (after a number of letters or in the first paragraph).

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic