司司司司司

Menu

WordPress优化 - 批量翻译中文标签别名为英文

批量修改现有标签的中文别名。

 

  1. //批量翻译Tags
  2. add_filter( 'bulk_actions-edit-post_tag', 'codebye_bulk_actions_tags' );
  3.  
  4. function codebye_bulk_actions_tags( $bulk_array ) {
  5.  
  6. $bulk_array['trans_chinese_tags'] = '中文别名翻译';
  7. return $bulk_array;
  8. }
  9.  
  10. add_filter( 'handle_bulk_actions-edit-post_tag', 'codebye_bulk_action_handler', 10, 3 );
  11.  
  12. function codebye_bulk_action_handler( $redirect, $doaction, $object_ids ) {
  13.  
  14. // do something for "中文别名翻译" bulk action
  15. if ( $doaction == 'trans_chinese_tags' ) {
  16. foreach ( $object_ids as $tax_id ) {
  17. wp_update_term($tax_id, 'post_tag', array('slug' => ''));
  18. }
  19. }
  20.  
  21. return $redirect;
  22. }

https://www.codebye.com/wordpress-seo-translate-chinese-term-slug-to-english.html

— 于 共写了614个字
— 文内使用到的标签:

Leave a Reply

Your email address will not be published. Required fields are marked *