How to stop WordPress from calling _find_post_by_old_slug ()

A kernel function that gets the record ID to redirect from the old url to the new one.

Used in the wp_old_slug_redirect () function , which redirects if the record ID was found.

Function algorithm _find_post_by_old_slug():

  • Creates the basis for the SQL query to find the record ID by the passed post type and the specified value in the meta field with the key _wp_old_slug equal to get_query_var (‘name’) .
  • Refines the query based on get_query_var (‘year’) , get_query_var (‘monthnum’) , get_query_var (‘day’) if the year, month, day of publication is used in the CNC record.
  • Using $ wpdb-> get_var () makes a request and returns the record ID.

Why WordPress call _find_post_by_old_slug ()

It is for redirect purpose  wp_old_slug_redirect() from preventing 404 and direct to _wp_old_slug that helps in fixing 404 posts.

You can stop it by simple emptying the function in wp-includes/query.php


function _find_post_by_old_slug( ) {

}

So, this way you can use your direct redirection plugin and handle the redirect on your WordPress site independently.

Leave a Reply

Your email address will not be published. Required fields are marked *