让Qtranslate 支持 Custom Taxonomy

If you wanted to automatically detect taxonomies, and then add translation edit fields here is some code:

如果你想要自动探测 Custom Taxonomy,然后给他们加上翻译字段, 把这段代码放在主题的 function.php 里。

 
function qtranslate_edit_taxonomies(){
   $args=array(
      'public' => true ,
      '_builtin' => false
   ); 
   $output = 'object'; // or objects
   $operator = 'and'; // 'and' or 'or'

   $taxonomies = get_taxonomies($args,$output,$operator); 

   if  ($taxonomies) {
     foreach ($taxonomies  as $taxonomy ) {
         add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');
         add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');        
      
     }
   }

}
add_action('admin_init', 'qtranslate_edit_taxonomies');
 

Comments

1,180 responses to “让Qtranslate 支持 Custom Taxonomy”