Skip to content

Instantly share code, notes, and snippets.

@alewolf
Last active May 30, 2023 23:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alewolf/1fe8e3b4cd3ceb8237ae2ffcd0282e32 to your computer and use it in GitHub Desktop.
Save alewolf/1fe8e3b4cd3ceb8237ae2ffcd0282e32 to your computer and use it in GitHub Desktop.
SearchWP Live Ajax Search results with thumbnails
<?php
/**
* This template adds thumbnails to your SearchWP Live Ajax Search results.
*
* Create a folder called searchwp-live-ajax-search in your child theme folder and copy this file in there.
* In order for this to work you require the SearchWP and SearchWP Live Ajax Search plugins installed and active.
*
*/
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $post_type = get_post_type_object( get_post_type() ); ?>
<div class="searchwp-live-search-result" style="white-space: nowrap;">
<span style="display: inline-block; margin-left: 5px;"><?php echo( get_the_post_thumbnail( $post->ID, array( 50, 50) ) ) ?></span>
<span style="display: inline-block;">
<p><a href="<?php echo esc_url( get_permalink() ); ?>">
<?php the_title(); ?> &raquo;
</a></p>
</span>
</div>
<?php endwhile; ?>
<?php else : ?>
<p class="searchwp-live-search-no-results">
<em><?php _ex( 'No results found.', 'swplas' ); ?></em>
</p>
<?php endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment