Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use a supplemental search engine with SWP_Query
<?php
/**
* Use SearchWP's SWP_Query to perform a search using a supplemental engine
*/
$swp_query = new SWP_Query(
array(
'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(); ?>
</div>
<?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
You can’t perform that action at this time.