【问题标题】:Add fields in custom taxonomy in WordPress admin for saved data在 WordPress 管理员的自定义分类中添加字段以保存数据
【发布时间】:2018-03-20 06:42:24
【问题描述】:

我想在表单字段中为我的插件在自定义分类中添加自定义字段,并显示保存的数据,如名称、slug 和描述。 有人提出建议!

【问题讨论】:

    标签: wordpress field custom-fields custom-taxonomy


    【解决方案1】:
    function custom_column_header( $columns ){
      $columns['address'] = 'Address'; 
      $columns['phoneno'] = 'Phone No';
    
      return $columns;
    }
    
    add_filter( "manage_edit-nwcm_news_category_columns", 'custom_column_header', 10);
    

    // 显示列值

    function custom_column_content( $value, $column_name , $term){
    
        if ($column_name === 'address') {
            $t_id = $term;
            $term_meta = get_option( "$t_id" ); 
            print_r($term_meta['address']);
        }
        if ($column_name === 'phoneno') {
            $t_id = $term;
            $term_meta = get_option( "$t_id" ); 
            print_r($term_meta['phone']);
        }
    
    }
    add_action( "manage_nwcm_news_category_custom_column", 'custom_column_content', 10, 3);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-07
      • 2013-10-02
      • 1970-01-01
      • 1970-01-01
      • 2019-02-28
      相关资源
      最近更新 更多