如何解决我需要在自定义帖子分类法类别中添加一个选项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 举报,一经查实,本站将立刻删除。