-2

I've install the new Twenty Fourteen theme for WordPress. I don't know how add summary text of posts on my front page.

All old tutorials like this does not work with new theme.

Any suggestions on how to solve this

| improve this question | | | | |
1

The twentyfourteen index page calls

get_template_part( 'content', get_post_format() );

inside the loop. So the content of the loop resides in template files with the name content-{$post_format}.php. All posts that does not have a post format uses content.php to display the post data

If you look at content.php, these lines are where the content is retrieved and displayed

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

By default, full post content are shown on all pages, except on the search page. To display excerpts on the home page as well, you will need to modify this section of code. All you need to do is to tell wordpress that when you are on the homepage (conditional tag is_home), show excerpts instead of full content.

Simply change this line

<?php if ( is_search() ) : ?>

to

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

EDIT

Remember to make this changes in a child theme. Never make changes to the theme itself

EDIT 2

If you are using a static front page, you should use is_front_page() instead of is_home(). Go and check out how to make use of Conditional Tags. You should then try

<?php if ( is_search() || is_front_page() ) : ?>

For info on excerpts, go and check out my (almost complete) post on excerpts

| improve this answer | | | | |
  • @goose Don't you need to do this for every post format file? – Brad Dalton Jul 21 '14 at 18:36
  • Hahaha, no Brad. It will break your shortcodes and html tags, which in turn will break your images, videos and audio files. That is why the post format templates only display full content, not excerpts. This is what your code will do unfortunately – Pieter Goosen Jul 21 '14 at 18:45
  • the_excerpt also strips out HTML & shortcodes – Brad Dalton Jul 21 '14 at 20:28
  • i need in content.php change: <?php if ( is_search() ) : ?> to <?php if ( is_search() || is_home() ) : ?> ? i do this but not work again is full text on front page ? – user2047800 Jul 21 '14 at 20:50
  • In my theme folder, in content.php i need change this: <?php if ( is_search() ) : ?> to <?php if ( is_search() || is_front_page() ) : ?> I do this and again is full text on front page, what i need to do ? Thanks for help. – user2047800 Jul 22 '14 at 15:34

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.