I'm trying to make my blog posts show an excerpt but can't seem to do it manually. My blog site is here.

I've gotten this snippet from the wordpress.org site

<?php the_excerpt(); ?>

and it tells me to replace the

<?php the_content(); ?>

with it. However I can't just replace it my index.php file as then it excerpts everything. (Maybe because of how my index.php file is set up?)

 * The main template file.

get_header(); ?>

        <div id="main">

                <?php while ( have_posts() ) : the_post(); ?>

                <?php get_template_part( 'content', 'page' ); ?>

                <?php endwhile; // end of the loop. ?>

                <?php if (function_exists("pagination")) {
                } ?>

        </div><!-- #main -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

I've tried to replace the have_posts() and then replace the second line of code and then even alter this lines:

and I get my excerpt under my post in my post but then it makes my website REALLY slow.

For some reason my choices for only showing summary in Settings > Review don't apply so I'm having to do it manually.

Any help is appreciated as to how I can customize this excerpt code to work with my blog.


As Linnea suggested I have updated the content-page.php page to this:

 * The template used for displaying separate posts on blog page.

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <span class="entry-header">
        <h1 class="blog entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        <h2 class="blog entry-subtitle">Posted on: <?php the_time('F j, Y'); ?></h2>
    </span><!-- .entry-header -->

    <div class="entry-content">
        <?php the_excerpt(); ?>
        <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'toolbox' ), 'after' => '</div>' ) ); ?>
        <?php edit_post_link( __( 'Edit', 'toolbox' ), '<span class="edit-link">', '</span>' ); ?>

    </div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->

Where the <?php the_excerpt(); ?> is now used to be <?php the_content('<br/><br/>CONTINUE READING...'); ?> however there is no change to my blog entries on my blog. Maybe there is another area I should be looking?

  • What does you content-page.php code looks like will paste that code as well to see. – Maqk Jan 29 '16 at 21:55
  • Thanks for the reply Maqk. I've updated my question with that code. – kia4567 Jan 29 '16 at 23:58
  • try looking for a home.php instead of index.php and if it uses a different template part. – majick Jan 30 '16 at 0:52
  • Thanks for the suggestion majick. I have no home.php file in my custom theme. Is that bad? – kia4567 Jan 30 '16 at 1:14

It looks like your index.php file calls the content-page.php file.

The code you are looking to change is probably in the content-page.php file. The key is this line:

get_template_part( 'content', 'page' );

It is directing WordPress to load content-page.php

  • Thanks for the speedy reply Linnea! I've updated my question with my findings. It's still not working however I have a feeling we're close! Do you know why it might not be working still? – kia4567 Jan 29 '16 at 23:35
if ( has_excerpt() && !is_single() ) {
    echo '<a class="more-link" href="'. esc_url( get_permalink() ) .'">'. __("Continue reading","textdomain") .'</a>';
    the_content( __( 'Continue reading', 'textdomain' ) );

    wp_link_pages( array(
        'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'textdomain' ) . '</span>',
        'after'       => '</div>',
        'link_before' => '<span>',
        'link_after'  => '</span>',
} ?>

I Hope this should work for you.

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.