Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bis_detect_query_order($url) {
- // Correct order
- $correct_args_order = array('post_type', 'product_cat', 'pa_brand');
- $get_args = parse_url($url, PHP_URL_QUERY);
- // Get an array with $_GET params
- parse_str($get_args, $get_args_array);
- // Get the names of keys
- $get_args_order = array_keys($get_args_array);
- // Compare the arrays
- if($get_args_order !== $correct_args_order) {
- $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
- wp_safe_redirect($shop_page_url, 301);
- exit();
- }
- }
- add_action('template_redirect', 'bis_detect_query_order', 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement