我需要在自定义帖子分类法类别中添加一个选项https://prnt.sc/uvonej

问题描述

我正在尝试在类别上添加复选框选项,但是我的代码无法正常工作 好像有些错误,您可以通过保存表单让我知道实际的代码吗? 我可以在我的function.PHP中使用该代码

我的分类名称是产品类别,帖子类型是产品

所以我需要添加复选框或单选按钮 像这样(https://prnt.sc/uvonej

这是我正在使用的代码

function products_taxonomy_custom_fields($tag) {  
   // Check for existing taxonomy Meta for the term you're editing  
    $t_id = $tag->term_id; // Get the ID of the term you're editing  
    $term_Meta = get_option( "taxonomy_term_$t_id" ); // Do the check  
?>  
  
<tr class="form-field">  
    <th scope="row" valign="top">  
        <label for="products_id"><?PHP _e('Main Box'); ?></label>  
    </th>  
    <td>  
        <input type="checBox" name="term_Meta[products_id]" id="term_Meta[products_id]" size="25" style="width:60%;" value="<?PHP echo $term_Meta['products_id'] ? $term_Meta['products_id'] : ''; ?>"><br />  
       
    </td>  
</tr>  
  
<?PHP  
} 

// A callback function to save our extra taxonomy field(s)  
function save_taxonomy_custom_fields( $term_id ) {  
    if ( isset( $_POST['term_Meta'] ) ) {  
        $t_id = $term_id;  
        $term_Meta = get_option( "taxonomy_term_$t_id" );  
        $cat_keys = array_keys( $_POST['term_Meta'] );  
            foreach ( $cat_keys as $key ){  
            if ( isset( $_POST['term_Meta'][$key] ) ){  
                $term_Meta[$key] = $_POST['term_Meta'][$key];  
            }  
        }  
        //save the option array  
        update_option( "taxonomy_term_$t_id",$term_Meta );  
    }  
} 

这是我的毒物学名称(由CPT代码创建) https://prnt.sc/uvopcj

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)