Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Last active July 11, 2022 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save searchwpgists/eeca325fe69ff293dd86d46b2b5fca2d to your computer and use it in GitHub Desktop.
Save searchwpgists/eeca325fe69ff293dd86d46b2b5fca2d to your computer and use it in GitHub Desktop.
Integrate SearchWP with JetSmartFilters search using JetEngine Listing Grid to display results
<?php
// Integrate SearchWP with JetSmartFilters search using
// JetEngine Listing Grid to display results.
// @link https://searchwp.com/documentation/knowledge-base/compatibility-with-jetsmartfilters-for-elementor/
add_action( 'pre_get_posts', function( $wp_query ) {
if (
! isset( $wp_query->query['jet_smart_filters' ] )
|| empty( $wp_query->query['s'] )
) {
return;
}
$swp_query = new \SWP_Query( array(
'engine' => 'default',
's' => $wp_query->query['s'],
'fields' => 'ids',
'nopaging' => true
) );
$results = ! empty( $swp_query->posts ) ? $swp_query->posts : array( 0 );
$wp_query->set( 'post__in', $results );
$wp_query->set( 'post_type', 'any' );
$wp_query->set( 'post_status', 'any' );
$wp_query->set( 'orderby', 'post__in' );
$wp_query->set( 'order', 'DESC' );
$wp_query->set( 's', false );
}, 9999 );
@nreljed
Copy link

nreljed commented Jul 9, 2022

Hi ,
I'm trying to add the second Supplemental engine, is that okay?

$swp_query = new \SWP_Query( array(
'engine' => 'default', 'supplemental',

it doesn't seem to work

or maybe like this?

$swp_query = new \SWP_Query( array(
		'engine'   => 'default',
                 'engine'   => 'supplemental',

It still does not work

can you tell us how to integrate several engines ?

Capture d’écran 2022-07-09 185525

in Supplemental I only added the users as it is not possible to use them in default

@BrElio
Copy link

BrElio commented Jul 11, 2022

It is not possible to combine multiple engines. You can use only one engine at the time.
If you need further help please contact our support.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment