在做了大量的研究和尝试不同的事情后,我看到了这个页面https://core.trac.wordpress.org/ticket/50976 这与我的问题不完全相同,但这也是破坏我的网站的原因。
为了解决这个问题,不必更改我的URL结构,也不必让google重新索引我的所有页面,我必须使用某些模板(利用了示例。local/courses/1234/?title=something)获取所有页面的列表,然后为每个页面创建一个add\\u rewrite\\u规则。
/**
* Register new rewrite rules
*/
function rewrite_pagination_rules_for_content_items() {
/* get list of pages the rewrite is required for based on a particular template used */
$pages = get_list_of_paginated_pages();
foreach($pages as $page) {
/* strip off domain name and first slash */
$domain_start = strpos($page[\'url\'],\'://\');
$domain_finish = strpos($page[\'url\'],\'/\',$domain_start+3);
$url = substr($page[\'url\'],$domain_finish+1);
$post_id = $page[\'id\'];
//echo \'<br/>url = \'.$url.\' post id = \'.$post_id;
add_rewrite_rule("^(.*){$url}([0-9]*)/?$",
\'index.php?page_id=\'.$post_id,
\'top\');
add_rewrite_tag(\'%id%\',\'([0-9]*)\');
}
}
add_action(\'init\', \'rewrite_pagination_rules_for_content_items\');