Skip to content

Instantly share code, notes, and snippets.

@wickcreative
Created March 11, 2015 22:00
Show Gist options
  • Select an option

  • Save wickcreative/651f9d9ea2435c3939e2 to your computer and use it in GitHub Desktop.

Select an option

Save wickcreative/651f9d9ea2435c3939e2 to your computer and use it in GitHub Desktop.
<?php global $post; ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php if( $post instanceof SearchWPTermResult ) : ?>
<div class="searchwp-live-search-result">
<p><a href="<?php echo $post->link; ?>">
<?php echo $post->name; ?> (<?php echo $post->taxonomy; ?>) &raquo;
</a></p>
</div>
<?php else : setup_postdata( $post ); ?>
<?php $post_type = get_post_type_object( get_post_type() ); ?>
<div class="searchwp-live-search-result">
<p><a href="<?php echo esc_url( get_permalink() ); ?>">
<?php the_title(); ?> (<?php echo esc_html( $post_type->labels->singular_name ); ?>) &raquo;
</a></p>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<p class="searchwp-live-search-no-results">
<em><?php _ex( 'No results found.', 'search results' ); ?></em>
</p>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment