Use a supplemental search engine with SWP_Query
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 | |
/** | |
* 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