My search results page is showing full pages instead of just part of a page and I can't figure out how to change it. I feel like I changed it TO show the full page but I can't remember how I did that and now I want to change it back.
Here is my search.php code.
<?php get_header(); ?>
<div id='container'>
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php printf( smt_translate( 'searchresults' ), get_search_query() ); ?></h1>
</header><!-- .page-header -->
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<?php
/*
* Run the loop for the search to output the results.
* If you want to overload this in a child theme then include a file
* called content-search.php and that will be used instead.
*/
get_template_part( 'content', 'get_post_format()' );
// End the loop.
endwhile;
// Previous/next page navigation.
get_template_part('navigation');
// If no content, include the "No posts found" template.
else :
get_template_part( 'content', 'none' );
endif;
?>
</div>
I'm using yoast seo and elementor plugins, so I don't know if that's affecting anything either. Any tips pointing me in the right direction would be great! Everything I've read online says to replace the_content with the_excerpt, but all I have are "content" and I tried replacing those but it either did nothing or search results came up blank.
Thanks!
get_template_part( 'content', 'get_post_format()' );
is the line that's telling it to display the full contents. Instead of calling a template part, try replacing that full line withthe_excerpt();
.search-excerpt
) and just change the call tothe_content()
there tothe_excerpt
. You can then callget_template_part('search-excerpt')
insearch.php
.