add_rewrite_rule()
无法自动为您创建永久链接结构。您应该使用wp_link_pages_link 滤器E、 g:
add_filter(\'wp_link_pages_link\', function($link, $i)
{
global $post, $photo_id;
if ($photo_id && \'gallery\' === $post->post_type)
$link = $link . \'/\' . intval($photo_id) . \'/\';
return $link;
}, PHP_INT_MAX, 2);
那么,您必须使用
add_rewrite_tag() 让WordPress知道
photo
查询字符串:
add_action(\'init\', function()
{
add_rewrite_tag(\'%photo%\', \'([0-9]+)\');
add_rewrite_rule(\'^gallery/([^/]+)/([0-9]+)/([0-9]+)/?$\', \'index.php?post_type=gallery&name=$matches[1]&page=$matches[2]&photo=$matches[3]\', \'top\');
}, 0, 0);