wordpress添加文章分类与标签时如何把别名自动保存为id

2025年02月04日 建站教程

wordpress新增文章分类与标签会以别名作为链接,那么如何把别名自动保存为id呢?下面web建站小编给大家简单介绍一下具体实现方法!

找到主题下functions.php文件,新增以下代码:

function alias_to_id_slug($term_id,$tt_id,$taxonomy){
  wp_update_term( $term_id, $taxonomy, $args = array('slug' => $term_id) );
}
add_action( 'create_term', 'alias_to_id_slug', $priority = 10, $accepted_args = 3 );

本文链接:http://so.lmcjl.com/news/22566/

展开阅读全文
相关内容