您可以这样简单地编写自己的函数:
function get_old_link($url) {
global $wpdb;
// get only url path
$parse = parse_url($url);
$path = trim($parse[\'path\'], "/");
// get last part as slug
$arr = explode("/", $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);
}
注意:可以改进此功能。我只想告诉你方向。