认为articles
是该类别的鼻涕虫。
1。添加自定义重写规则:
add_action(\'init\', function()
{
add_rewrite_rule(\'^articles/([^/]+)/?$\', \'index.php?name=$matches[1]\', \'top\');
}, 10, 0);
2。过滤帖子链接:
add_filter(\'post_link\', function($post_link, $post, $leave_name = false, $sample = false)
{
if ( has_category(\'articles\', $post) ) {
$post_link = str_replace(\'/\' . $post->post_name, \'/articles/\' . $post->post_name, $post_link);
}
return $post_link;
}, 10, 4);
仅此而已。在您的
functions.php
记住刷新你的permalink结构。
References: