I can’t seem to get the search query to show on my page. It does persist in the search box but Ideally I’d like to add a title to the page saying “You searched for…”
Echoing out the get_search_query(); isn’t returning anything. I’ve tried it both inside and outside of the loop.
It’s a pretty simple template …. here’s what I have:
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php $search_query = get_search_query(); ?>
<?php print_r($search_query);?>
<div id="thumbnails">
<?php while ( have_posts() ) : the_post();?>
<?php
// Get the Post category
$categories = get_the_category();
$className = strtolower(esc_html( $categories[0]->name ));
?>
<div class="thumbnail <?php echo $className;?>">
<a class="thumbnail-link" href="<?php the_permalink();?>">
<div class="thumbnail-overlay-text">
View Image
</div>
</a>
<?php the_post_thumbnail('thumbnail'); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php get_footer(); ?>