我正在使用这段代码向Wordpress分类法添加一个表单:
function albums_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[custom_term_meta]"><?php _e( 'Example meta field', 'albums' ); ?></label>
<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
<p class="description"><?php _e( 'Enter a value for this field','albums' ); ?></p>
</div>
<?php
}
add_action( 'albums_add_form_fields', 'albums_taxonomy_add_new_meta_field', 10, 2 );
该值保存良好。但是,如何在模板上输出用户在表单中填写的值?在前端使用这个值的php函数是什么?
谢谢。
只是猜测一下,在表单被重定向到的页面上尝试:
echo $_POST['term_meta']['custom_term_meta']