Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2015 15:59
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Use a supplemental search engine with SWP_Query
* Use SearchWP's SWP_Query to perform a search using a supplemental engine
$swp_query = new SWP_Query(
's' => 'coffee', // search query
'engine' => 'my_engine', // search engine
if ( ! empty( $swp_query->posts ) ) {
foreach( $swp_query->posts as $post ) : setup_postdata( $post ); ?>
<div class="search-result">
<h3><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<?php endforeach; wp_reset_postdata();
} else {
?><p>No results found.</p><?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment