Skip to content

Instantly share code, notes, and snippets.

@kwbtdisk
Last active October 20, 2020 02:24
Show Gist options
  • Save kwbtdisk/895a1a0045631a07f4d08af4642ba78c to your computer and use it in GitHub Desktop.
Save kwbtdisk/895a1a0045631a07f4d08af4642ba78c 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