你有rewrite_rules
在wp\\U选项表中。从那里,你的应用程序可以知道wordpress将来将要重写什么,以及在索引后将如何重写。php。您可以将JS中的正则表达式与wp\\U选项数据一起使用,以自定义应用程序响应。
更新
我需要一段代码来确定当前页面/帖子的性质,以便根据返回动态使用不同的模板-
if(!function_exists(\'get_nature_of_post\')):
function get_nature_of_post() {
global $wp_query;
$wpq = json_decode(json_encode($wp_query),true);
$check = array("is_single","is_page","is_archive","is_author","is_category","is_tax","is_search","is_home","is_404","is_post_type_archive");
$page_identifiers = array_intersect_key($wpq,array_flip($check));
$page_identifiers = array_filter($page_identifiers);
$keys = array_flip(array_keys($page_identifiers));
$case[\'home\'] = array_flip(array(\'is_home\'));
$case[\'search\'] = array_flip(array(\'is_search\'));
$case[\'archive\'] = array_flip(array(\'is_archive\',\'is_post_type_archive\'));
$case[\'taxonomy\'] = array_flip(array(\'is_archive\',\'is_tax\'));
$case[\'single\'] = array_flip(array(\'is_single\'));
$case[\'page\'] = array_flip(array(\'is_page\'));
$home = !array_diff_key($case[\'home\'], $keys) && !array_diff_key($keys, $case[\'home\']);
$archive = !array_diff_key($case[\'archive\'], $keys) && !array_diff_key($keys, $case[\'archive\']);
$search = !array_diff_key($case[\'search\'], $keys) && !array_diff_key($keys, $case[\'search\']);
// var_dump($archive);
$taxonomy = !array_diff_key($case[\'taxonomy\'], $keys) && !array_diff_key($keys, $case[\'taxonomy\']);
// var_dump($taxonomy);
$single = !array_diff_key($case[\'single\'], $keys) && !array_diff_key($keys, $case[\'single\']);
// var_dump($single);
$page = !array_diff_key($case[\'page\'], $keys) && !array_diff_key($keys, $case[\'page\']);
// var_dump($page);
switch (!false) {
case $archive: return \'archive\'; break;
case $taxonomy: return \'taxonomy\'; break;
case $single: return \'single\'; break;
case $page: return \'page\'; break;
case $search: return \'search\'; break;
case $home: return \'home\'; break;
default: return false;
}
}
endif;