Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
global $post;
$originalPost = $post;
$engine = SearchWP::instance(); // instatiate SearchWP
$supplementalEngineName = 'my_search_engine'; // search engine name
$terms = 'soccer'; // search terms, space separated
$page = 1; // pagination
// perform the search
$posts = $engine->search( $supplementalEngineName, $terms, $page );
// some metrics to build pagination
$foundPosts = $engine->foundPosts;
$maxNumPages = $engine->maxNumPages;
// if we have results...
if( !empty( $posts ) )
{
// loop through results
foreach( $posts as $post ) : setup_postdata( $post ); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
}
$post = $originalPost;
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.