WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of the big problems my site staff has had with tags is the overwhelming number of similar or duplicate tags, due to the write-in ability.

I'm about to add new custom taxonomies to my site for them to use, but I'd like to avoid the problem we had with tags. I'm curious to know if I can turn off write-ins, so they can only be added manually through that taxonomy's part of the admin area. It's non-hierarchical, so they can still type in and the system will auto-complete and search for tags they might be looking for, which is great. I just don't want them to be able to create new tags from the post screen.

Is this possible? I was looking at the Taxonomies and register_taxonomy() pages in the Codex, and thought maybe the "rewrite" function might be what I'm looking for, but I don't think it is now.

share|improve this question
up vote 6 down vote accepted

Here is what I came up with, seems to work:

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;

This is for tags, you can easily extend second function to handle custom taxonomies.

share|improve this answer
Wow, that works pretty well! Just one thing though, it seems you can still hit "enter/return" or the "Add" button, and the tag will still show up underneath as if it's been or going to be added. It doesn't actually write the tag upon saving or publishing, which is good, but it still might give someone writing the post a false sense of having tagged their post instead of finding one that actually exists. I tried some else statements in there, but nothing really changed the result. Any suggestions? – Chris Jan 3 '11 at 19:35
@Chris sorry, admin interface is so not my area of expertise. This filtering out of tags on post save is best I can offer. – Rarst Jan 3 '11 at 20:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.