-
-
Save jchristopher/d6d1a0aec68f3cea6885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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