I have SearchWP included on my site. It works fine, with one exception: Supplemental Search Engine for Custom Post Type. I have implemented search engine for standard posts post type, which are my News with Setting up a Supplemental Search Engine: Step by Step tutorial.
Code in template that returns my results for News is:
global $post;
// retrieve our search query if applicable
$query = isset( $_REQUEST['swpquerypub'] ) ? sanitize_text_field( $_REQUEST['swpquerypub'] ) : '';
if( class_exists( 'SearchWP' ) ) {
$engine = SearchWP::instance();
$supplementalSearchEngineName = 'wyszukiwanie_publikacji';
$posts = $engine->search( $supplementalSearchEngineName, $query, $swppg );
}
and it works perfect.
But if I do same thing with my post type “publication” in archive-publication.php, I’m not getting results except one: my current page object. I think my problem is global $post call in custom post type loop. Anyway, as far as I know, I can call global $post inside loop of current post type, and it will return my post type objects, but it seems to work different. I’m trying to solve this for long time, and for now, I didnt find solution, so I’m asking you for help.