Wordpress-我可以获得给定路径的重写规则吗?

Wordpress-我可以获得给定路径的重写规则吗?,wordpress,url-rewriting,Wordpress,Url Rewriting,我正在编写一个插件,它将URL路由到自定义格式 简单地说,我想获得给定路径的重写规则,我可以这样做吗 例如,我需要一个函数,如下所示: $path = 'team/john-smith'; $rules = get_rules($path) $rules现在类似于 index.php?team=john-smith&post_type=team&name=john-smith; 或者,实际的重写规则数组(我可以自己构建字符串…) 您是否在includes/rewrite.

我正在编写一个插件,它将URL路由到自定义格式

简单地说,我想获得给定路径的重写规则,我可以这样做吗

例如,我需要一个函数,如下所示:

$path = 'team/john-smith';

$rules =  get_rules($path)
$rules现在类似于

index.php?team=john-smith&post_type=team&name=john-smith;
或者,实际的重写规则数组(我可以自己构建字符串…)


您是否在includes/rewrite.php中看过此函数:

函数url\u to\u posted($url)

我的猜测是,要获得实际的重写规则,您可以使用:

global $wp_rewrite;
$rewrite = $wp_rewrite->wp_rewrite_rules();
或者调用
page\u rewrite\u rules()
。该文件中有一些有趣的代码

global $wp_rewrite;
$rewrite = $wp_rewrite->wp_rewrite_rules();