Created
September 11, 2019 16:11
-
-
Save skorasaurus/5cb1b47acf7e55fe4a5d8b6b1ec8a5a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(yes, I Know I should rename the 'simple' variable to something a lot more clearer...)