Redirections don’t work if URI contains “p” parameter

#525795
Viewing 3 replies - 1 through 3 (of 3 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with redirecting your custom post type.

    The ‘p’ parameter is triggered by WordPress before Rank Math redirects. You could use a WordPress ‘template_redirect’ filter instead. Please try this code snippet:

    
    add_action( 'template_redirect', 'redirect_jbjob');
    
    function redirect_jbjob() {
    	if (isset($_GET['post_type'])) {
    		$queried_post_type = $_GET['post_type'];
    	}else{
    		$queried_post_type = "";
    	}
    	if ( 'jb-job' ==  $queried_post_type ) {
        	wp_redirect(home_url(), 301);
    	}
    }
    

    You can refer to this guide for how to add code snippets: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Please let us know if you have questions.

    Thanks,
    That fixed my issue

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Redirections don’t work if URI contains “p” parameter’ is closed to new replies.