Last active
May 30, 2023 23:45
-
-
Save alewolf/1fe8e3b4cd3ceb8237ae2ffcd0282e32 to your computer and use it in GitHub Desktop.
SearchWP Live Ajax Search results with thumbnails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); ?> » | |
</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