i have a frontend Form to allow users to create their own recipes. Currently I'm using this to allow entering new tags:
function display( $submit_type, $post_id ){
$post_tags = get_the_terms( $post_id, 'recipe_tags' );
$post_tags = ( is_array($post_tags) ) ? $post_tags : array();
if( !empty($post_tags) ){
$names = array();
foreach ($post_tags as $term) {
$names[] = $term->name;
}
$post_tags = $names;
}
$post_tags = ( ! empty($post_tags) && is_array($post_tags) ) ? join(', ', $post_tags) : '';
$field = new Smk_Input( $this->id, $post_tags, array(
'title' => __('Tags', 'smk_theme'),
'description' => __('Enter a maximum of 15 tags separated by comma.', 'smk_theme'),
'class' => 'fullwidth',
'row_style' => 'inline',
) );
echo $field->render();
}
So, I need that "$field" make them existing tags suggestions, just like Wordpress does on the post editing backend.
Can someone help me?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…