Skip to content

Instantly share code, notes, and snippets.

@skorasaurus
Created September 11, 2019 16:11
Show Gist options
  • Save skorasaurus/5cb1b47acf7e55fe4a5d8b6b1ec8a5a2 to your computer and use it in GitHub Desktop.
Save skorasaurus/5cb1b47acf7e55fe4a5d8b6b1ec8a5a2 to your computer and use it in GitHub Desktop.
function search_redirect_form() {
if (is_search() && ! empty( $_GET['simple'] ) ) {
if (isset($_GET['simple']) && $_GET['simple'] == 'dogpile') {
$query = sanitize_text_field($_GET["s"]);
wp_redirect(esc_url('theurl1'. $query));
exit();
}
if (isset($_GET['simple']) && $_GET['simple'] == 'altavista') {
$query = sanitize_text_field($_GET["s"]);
wp_redirect(esc_url('url2'. $query .'/field/all/mode/all/conn/and/order/nosort'));
exit();
}
if (isset($_GET['simple']) && $_GET['simple'] == 'askjeeves') {
$query = sanitize_text_field($_GET["s"]);
wp_redirect(esc_url('url3' . $query));
exit();
}
else {
$query = sanitize_text_field($_GET["s"]);
wp_redirect(esc_url($home_url . "?s=" . $query));
exit();
}
}
}
add_action( 'pre_get_posts', 'search_redirect_form', 1 );
@skorasaurus
Copy link
Author

(yes, I Know I should rename the 'simple' variable to something a lot more clearer...)

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