Skip to content

Instantly share code, notes, and snippets.

@manh-dan
Forked from kwbtdisk/in_your_functions.php
Created October 20, 2020 02:24
Show Gist options
  • Save manh-dan/b06f55dbfb3eace011efaffc28cd085a to your computer and use it in GitHub Desktop.
Save manh-dan/b06f55dbfb3eace011efaffc28cd085a to your computer and use it in GitHub Desktop.
[WordPress] Integration with Ajax Search Lite & Bogo (Adjust the seach query for the page's language)
// Adjust the seach query of Ajax Search Lite with Bogo
add_action('asl_query_add_args', 'ajax_search_light_and_bogo_integration', 100, 1);
function ajax_search_light_and_bogo_integration( $args ) {
global $wpdb;
// Bogo saves the page language into the cookie, so we can just pick it.
$loc = $_COOKIE['lang'];
if(!$loc) { return $args; }
$args['where'] .= <<<SQL
AND ID IN ((
SELECT post_id FROM $wpdb->postmeta
WHERE $wpdb->postmeta.meta_key = '_locale' AND $wpdb->postmeta.meta_value='$loc'
))
SQL;
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment