wordpress二次开发tags改为id显示(wordpress二次开发教程)
admin1159356年前1条评论
wordpress二次开辟tags改id显示,后缀加html,伪动态体例对于seo尤其友好.
应用文本编纂器关上以后主问题录下的functions.php,增添下列php代码:
终究显示体例:id+html形式展现
- 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;
- }
本文链接:https://addon.ciliseo.com/wordpress-er-ci-kai-fa-tags-gai-wei-id-xian-shi.html
网友评论
tjtlueit
回复优化内容布局,轻松解决Wordpress二次开发项目实现显示转换为id技术.