You can simply write your own function this way:
function get_old_link($url) {
global $wpdb;
// get only url path
$parse = parse_url($url);
$path = trim($parse['path'], "https://wordpress.stackexchange.com/");
// get last part as slug
$arr = explode("https://wordpress.stackexchange.com/", $path);
$slug = end($arr);
// find post id by meta_key and meta_value
$row = $wpdb->get_row("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_old_slug' AND meta_value="{$slug}"");
if(!empty($row->post_id))
return get_permalink($row->post_id);
}
Note: it is possible to make this function better. I only want to show you the direction.
Related Posts:
- Redirect Restricted Page to 404
- Redirect user to original url after login?
- Redirect to dashboard after login
- Make a video post redirect to next post after completion
- Site redirects to wrong url when saving settings
- Redirect blog page to latest post?
- WordPress site redirects to different wordpress domain on the same server after reuploading db backup
- WordPress Redirect based on the prescence of a cookie
- Links to an exisiting Page are now redirecting to a draft page?
- Random and Erroneous WordPress Redirect
- Redirect Old domain & posts to new domain homepage
- Redirecting users to referrer page after logging in using custom login form
- Remove lost password form and URL
- add_rewrite_rule to pass entire path as a single parameter
- What is the wordpress way of displaying local external content?
- How To Only Allow Users To View Their Own Buddypress Profiles? [closed]
- RedirectMatch and Redirect interfering with each other
- Menu links only using http after enabling https, unable to redirect http links
- some url does not redirect from http to https
- Why can’t I access files / directories outside of wordpress
- Return to where the user was, after log out
- Change ‘Back To Website’ link in wp-login.php
- How do I map a subdomain in wordpress to the primary domain in a multisite setup?
- Redirect the non-www version of the site to the www
- Load time cost of using a redirect plugin v direct .htaccess entry
- Right hook to redirect frontend visitors while respecting rest api plugins to run first?
- Redirect loop after changing nameserver [closed]
- Create a page that automatically redirects to latest post of a specific tag/category?
- Is it possible to incorporate username in a login redirect?
- How to make wordpress folder (/wordpress) redirect to /?
- Changing domain
- How to redirect on login to a specific page if a specific meta user is empty
- Redirecting amp url to non amp url
- How To Redirect /url.html to /url?
- Redirect htaccess does not work correctly with my new wordpress site
- Remove #wpcf7-f2450-o1 with Contact form 7 redirect [closed]
- Redirecting deleted posts url to another WordPress install
- 301 redirect from old URL structur to new
- Redirect each user to specific pages based on their role
- How to fix too many redirects when enabling SSL for site?
- Custom redirect user after login based on metadata
- wp_redirect () doesn’t work in nginx?
- Add Username to URL for redirect
- Log out and redirect to different URL
- How to get better performance for redirect from domain.tld/35 to domain.tld/full-permalink?
- Redirect deleted page URL ?p=xxxx
- Have WordPress post redirect to url when accesed from iPad (Safari)
- I want to resolve Redirect Chain [closed]
- How to fix URL with pageid example /?p= too many redirection error
- Conditional redirect to several pages
- Adding query string parameters to URL with same name as custom post type gives 404 error
- Dynamic redirect
- Create header.php redirect in WordPress and with WPML
- Redirect to home if page doesn’t exists [duplicate]
- Redirect all links form a category to new links on new category
- My redirect URL doesn’t show any pages on my website [closed]
- Forced Redirect on a server migration
- Site Address and WordPress Address settings when using a load balancer
- Prevent “/login” to redirect to “/wp-login”
- Redirect home resets (qtranslate) language
- Redirect certain pages if user logged in
- Login redirect shows white page in firefox
- Redirect to post_id?
- wp_login_form redirect
- Date based redirects of posts that no longer exist
- How can I disable redirect domains?
- When i try to enter subdomain i’m redirected to main domain
- Change my URL from https://www.domain.com to https://domain.com
- redirect wordpress post to new subfolder site on same domain
- Use a 301 to Redirect any 404 from at the blog post level to the blog archive
- Re-Direct ALL Users to the Home Page IF not logged in
- Need to redirect home page only on Woocommerce site if user logged in
- Redirect to dashboard user once you click on Publish page
- Random redirect to wp-admin/install.php
- Changing auth_redirect() page
- How to redirect returning users who previously logged in?
- wordpress redirect error in xampp
- Redirect based on referer using Advanced Custom Fields
- Swapping current old site to new WordPress site – need to check I’m doing it right
- how redirect users to custom login page when user comment must “login to reply” is clicked?
- Redirect User to Specific Page
- Allow GET request on certain page
- .htaccess redirect for old subfolder installation to new subfolder installation and https
- How to modify the WordPress comes with redirect
- PHP Mistake – Whats wrong here?
- On login redirect to different homepage if user is using a mobile
- Multisite hide subdirectory
- Redirect user to login and then to page where they came from
- htaccess and redirect to new url using regex
- How to redirect correctly a root domain to a subdomain in a subfolder?
- redirect attachment page to category page
- Google PageSpeed: Avoid landing page redirects?
- login_redirect for Mobile Web
- How to make my homepage automatically redirect to an external website?
- How does the flow of htaccess files in sub-directories work
- Redirect to a subdirectory frontpage using without using a WP plugin- what files to edit, and how?
- 404 Not Found with All Cloaking plugins
- Stopping media file redirects
- Is there a way to redirect people from a page on my .com website to a corresponding page on my .co.uk website if they are in the UK
- How to find out what is causing redirect of static content?