Skip to content

Instantly share code, notes, and snippets.

@msaari
Last active September 22, 2020 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msaari/fd754d021223b5ad9b96ca8f601b7030 to your computer and use it in GitHub Desktop.
Save msaari/fd754d021223b5ad9b96ca8f601b7030 to your computer and use it in GitHub Desktop.
SearchWP Live Ajax Search template with support for users and taxonomies
<?php
/**
* Save this as searchwp-live-ajax-search/search-results.php inside your theme.
*/
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); if ( 'draft' === $post->post_status ) continue; ?>
<?php $post_type = get_post_type_object( get_post_type() ); ?>
<div class="searchwp-live-search-result" role="option" id="" aria-selected="false">
<p><a href="<?php echo esc_url( get_permalink() ); ?>">
<?php the_title(); ?> (<?php $label = isset( $post_type->labels ) ? $post_type->labels->singular_name : ucfirst(get_post_type()); echo esc_html( $label ); ?>) &raquo;
</a></p>
</div>
<?php endwhile; ?>
<?php else : ?>
<p class="searchwp-live-search-no-results" role="option">
<em><?php esc_html_x( '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