admin管理员组

文章数量:1318580

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

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

Share Improve this question edited Jul 21, 2014 at 21:11 Brad Dalton 6,9652 gold badges36 silver badges47 bronze badges asked Jul 21, 2014 at 17:19 user2047800user2047800 11 silver badge3 bronze badges 4
  • 1 thanks all for try to help but unfortunately all this solutions not work, i found this plugin who fix all my problems, wordpress/plugins/easy-custom-auto-excerpt – user2047800 Commented Jul 22, 2014 at 15:52
  • I've added a solution in this link, hope it helps to you. codex.wordpress/… – Dario Chuquilla Commented Dec 12, 2014 at 19:49
  • No, you didn't fix the problems with the plugin. It simply ignores it. – Wim Vincken Commented Oct 21, 2020 at 9:29
  • @WimVincken you posted a comment as an answer, don't do that. I've moved it here as I couldn't see what it was responding to, this question and its answers don't mention plugins, I don't know what you're referring to – Tom J Nowell Commented Oct 21, 2020 at 10:09
Add a comment  | 

1 Answer 1

Reset to default 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

本文标签: excerptModify Twenty Fourteen Home Page Content Limit amp Add Read More Link