以下是我的想法,似乎奏效了:
add_filter( \'pre_post_tags_input\', \'no_tags_input_create\' );
add_filter( \'pre_post_tax_input\', \'no_tax_input_create\' );
function no_tags_input_create($tags_input) {
$output = array();
foreach( $tags_input as $tag )
if( term_exists( $tag, \'post_tag\') )
$output[] = $tag;
return $output;
}
function no_tax_input_create($tax_input) {
if( !isset($tax_input[\'post_tag\']) )
return $tax_input;
$output = array();
$tags = explode(\',\', $tax_input[\'post_tag\']);
foreach( $tags as $tag )
if( term_exists( $tag, \'post_tag\') )
$output[] = $tag;
$tax_input[\'post_tag\'] = implode(\',\',$output);
return $tax_input;
}
这是针对标记的,您可以轻松地扩展第二个函数来处理自定义分类法。