下面的代码工作正常,但我不知道它是否正确编码。有人能确认或评论代码吗?
add_action(\'init\', \'news_rewrite\');
function news_rewrite() {
global $wp_rewrite;
add_permastruct(\'news\', \'news/%year%/%postname%/\', true, 1);
add_rewrite_rule(\'news/([0-9]{4})/(.+)/?$\', \'index.php?news=$matches[2]\', \'top\');
add_rewrite_rule(\'^news/([0-9]{4})/?\',\'index.php?post_type=news&year=$matches[1]\',\'top\');
}