1。添加新的重写规则:
add_action(\'init\', function()
{
add_rewrite_rule(\'^dog/([^/]+)/?$\', \'index.php?cat=dog&name=$matches[1]\', \'top\');
}, 10, 0);
2。过滤帖子链接:
add_filter(\'post_link\', function($post_link, $post, $leave_name = false, $sample = false)
{
if ( is_object_in_term($post->ID, \'category\', \'DOG\') ) {
$post_link = str_replace($post->ID . \'-\', \'\', $post_link);
}
return $post_link;
}, 10, 4);
在你的
functions.php
. 希望它对你有用!