Skip to content

Instantly share code, notes, and snippets.

@tkc49
Last active August 16, 2017 06:21
Show Gist options
  • Save tkc49/e1114c0e7203cb1a37bc to your computer and use it in GitHub Desktop.
Save tkc49/e1114c0e7203cb1a37bc to your computer and use it in GitHub Desktop.
タームをカスタマイズする際に必要なフック
<?php
public function plugins_loaded(){
add_action ( 'edited_term',array($this,'save_extra_category_fileds')); // 編集画面の保存
add_action ( 'created_term',array($this,'save_extra_category_fileds')); // 新規追加の保存
}
public function init(){
$args=array('public' => true,'_builtin' => false ); // builtin=false(WordPressが設定してるものは省く)
$output = 'names'; // or objects
$operator = 'and'; // 'and' or 'or'
$taxonomies=get_taxonomies($args,$output,$operator);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy ) {
add_action ( $taxonomy.'_edit_form_fields', array($this,'extra_edit_tax_fields'));
add_action ( $taxonomy.'_add_form_fields', array($this,'extra_add_tax_fields'));
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment