Hadi Reda Hadi Reda - 2 months ago 8
PHP Question

Wordpress doesn't show excerpt when comments are off

i have a problem with my wordpress theme. It works, but when i would like to turn the comments off, it doesn't show me the excerpt.

The first picture shows how it look like when comments are allowed, the second picture shows it when comments are not allowed.

Comments allowed

Comments off

Here is the code snippet from content.php page:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<div class="entry-header-title">


<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h1>
<?php endif; // is_single() ?>

<span class="entry-meta-date">
<?php twentythirteen_entry_date(); ?>
<span>|</span>


<?php if ( comments_open() && ! is_single() ) : ?>
<span class="entry-comments" >
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a Reply', 'twentythirteen' ) . '</span>', __( '1 Comment', 'twentythirteen' ), __( '% Comments', 'twentythirteen' ) ); ?>
</span><!-- .entry-comments -->

</span><!-- .entry-meta -->

<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>


</div>


</header><!-- .entry-header -->

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

<?php endif; ?>

<footer class="entry-meta">



<?php endif; // comments_open() ?>

<div class="entry-labels">
<?php twentythirteen_entry_meta(); ?>
</div>

<div class="entry-share">
<?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
</div>




<div class=".post-spacer">
</div>

</footer><!-- .entry-meta -->
</article><!-- #post -->

<div class="linkwithin_div"></div>

Answer

You accidentally deleted an <?php endif;?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<div class="entry-header-title">


<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h1>
<?php endif; // is_single() ?>

<span class="entry-meta-date">
    <?php twentythirteen_entry_date(); ?>
<span>|</span>


<?php if ( comments_open() && ! is_single() ) : ?>
    <span class="entry-comments" >
                <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a Reply', 'twentythirteen' ) . '</span>', __( '1 Comment', 'twentythirteen' ), __( '% Comments', 'twentythirteen' ) ); ?>
    </span><!-- .entry-comments -->

</span><!-- .entry-meta -->
//THIS ONE
<?php endif; // comments_open() ?>


<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
    <div class="entry-thumbnail">
        <?php the_post_thumbnail(); ?>
    </div>
<?php endif; ?>


</div>


</header><!-- .entry-header -->

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

<?php endif; ?>

<footer class="entry-meta">




    <div class="entry-labels">
    <?php twentythirteen_entry_meta(); ?>
    </div>

    <div class="entry-share">
        <?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
    </div>




    <div class=".post-spacer">
    </div>

Comments