Hello rlinn
Can you please add the below line of code by replacing code between line35-51.
if ( is_search() ) : // Only display Excerpts for Search
if ( is_singular( 'post' ) ){ ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php }
if ( is_page() ){ ?>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<?php }
?>
<?php else : ?>
<div class="entry-content">
<?php
/* translators: %s: Name of current post */
the_content( sprintf(
__( 'Continue reading %s <span class="meta-nav">→</span>', 'twentythirteen' ),
the_title( '<span class="screen-reader-text">', '</span>', false )
) );
wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) );
?>
</div><!-- .entry-content -->
<?php endif; ?>
Thread Starter
rlinn
(@rlinn)
Thanks for your reply. Your code gives neither the_content nor the_excerpt. I have a feeling that when is_search is TRUE then all the other conditionals (like is_singular and is_page) are FALSE.
I think that I’m going to need to use get_post_type() somehow.
Hello rlinn,
Yes We need to check the condition like this:
if ( get_post_type( get_the_ID() ) == "post" ) { ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php }
else { ?>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<?php }
?>
Thread Starter
rlinn
(@rlinn)
Thanks for your reply. I had tried that previously except I had used = instead of == after looking at get_post_type().
I have been able to modify your code to get the template working. Thank you.