wordpress文章tag标签默认链接是用中文字显示的,这样不利于seo,下面web建站小编教大家如何把链接改成id.html(非插件)。
打开主题functions.php,在最下面插入以下代码:
add_action('generate_rewrite_rules','tag_rewrite_rules');
add_filter('term_link','tag_term_link',10,3);
add_action('query_vars', 'tag_query_vars');
function tag_rewrite_rules($wp_rewrite) {
$new_rules = array(
'tag/(\d+)/feed/(feed|rdf|rss|rss2|atom).html' => 'index.php?tag_id=$matches[1]&feed=$matches[2]',
'tag/(\d+)/(feed|rdf|rss|rss2|atom).html' => 'index.php?tag_id=$matches[1]&feed=$matches[2]',
'tag/(\d+)/embed.html' => 'index.php?tag_id=$matches[1]&embed=true',
'tag/(\d+)/page/(\d+).html' => 'index.php?tag_id=$matches[1]&paged=$matches[2]',
'tag/(\d+).html' => 'index.php?tag_id=$matches[1]',
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
function tag_term_link($link,$term,$taxonomy) {
if($taxonomy=='post_tag') {
return home_url('/tag/'.$term->term_id.'.html');
}
return $link;
}
function tag_query_vars($public_query_vars) {
$public_query_vars[] = 'tag_id';
return $public_query_vars;
}
现在相关链接已经改变了,但是页面是404,需要重新打开“固定链接”页面重新保存!
上面是“wordpress文章tag标签链接改成id.html(非插件)”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2396.html
workflows工作流
一名男子跪在月球岩石表面看见小行星碰撞
图生图工作流:藏族姑娘ComfyUI工作流
一座千年九尾白狐玉雕ComfyUI工作流
森林里一只邪恶的树妖ComfyUI工作流
3D几何打印人体模型ComfyUI工作流
一座生动的点彩主义灯塔ComfyUI工作流
一辆在泥潭中奔跑的布加迪ComfyUI工作流
一位身着传统红色服装的女战士ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

数字滚动效果(兼容IE6/IE8)
3d文字动画效果
利用css绘画棋盘布局(象棋)
用svg画出游泳池动画效果
在线生成金属文字
制作一个好玩的倒计时
利用CSS3做一个星级评分样式
会议人员60s签到倒计时插件







