此代码段首先在帖子标题(非常右)之前显示(前缀)类别名称。
E、 g级
音乐:%Post\\u title%视频:%Post\\u title%歌词:%Post\\u title%新闻:%Post\\u title%生活风格:%Post\\u title%
E、 g关于类别音乐和;仅视频。
那么任何其他类别的其他帖子都不会显示任何前缀。。。
下面是代码片段:
add_filter(\'wp_title\', function ($title) {
if (is_single()) {
$categories = get_the_category(get_the_ID());
// Assuming the post has many categories will take the first
$category = reset($categories);
return $category->name .\': \'.$title;
}
return $title;
}
);