-
-
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)
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
// 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