wordpress tags标签改造id显示加后缀html显示,据说多seo比较友好,那么。
使用文本编辑器打开当前主题目录下的 functions.php,添加以下 php 代码:
/* 标签以id+html方式展示(molure.cn)*/
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;
}
温馨提示:本文最新于
2022-09-24 18:57:13进行了更新,某些文章内容具有时效性,若失效或有错误,请在下方留言。© 版权声明
THE END





![WP主题美化教程集锦[笔记]-楊仙森万事坞](https://bg.leohi.top/meili/img/leohi/meihuabiji.png)
![[Android]没认证的电视&盒子照样看奈飞的剧 – Netflix – Kodi Edition[安卓TV端]-楊仙森万事坞](https://img.leohi.top/images/2023/02/27/0284d4b9054b.jpg)
![2021喜剧动作《警醒》HD1080P[中英双字]-楊仙森万事坞](https://p0.meituan.net/moviemachine/c31af794101eb2ccdd31fb4e3fd70b04236578.jpg@464w_644h_1e_1c)






















暂无评论内容