Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active January 10, 2026 21:24
Show Gist options
  • Select an option

  • Save wplit/1c00b753036b44ef7762e2d83135ff97 to your computer and use it in GitHub Desktop.

Select an option

Save wplit/1c00b753036b44ef7762e2d83135ff97 to your computer and use it in GitHub Desktop.
Redirect WordPress search to WPGB search format
<?php
/**
* Redirect WordPress search to WPGB search format
*/
add_action('template_redirect', function() {
if (isset($_GET['s']) && !empty($_GET['s'])) {
$search_query = sanitize_text_field($_GET['s']);
$redirect_url = home_url('/search/') . '?_search_filter=' . urlencode($search_query);
wp_safe_redirect($redirect_url, 301);
exit;
}
}, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment