Title: post_tags_meta_box
Published: April 25, 2014
Last modified: August 20, 2026

---

# post_tags_meta_box( WP_Post $post, array $box )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#wp--skip-link--target)

Displays post tags form fields.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#parameters)󠁿

 `$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)required

Current post object.

`$box`arrayrequired

Tags meta box arguments.

 * `id` string
 * Meta box `'id'` attribute.
 * `title` string
 * Meta box title.
 * `callback` callable
 * Meta box display callback.
 * `args` array
 *  Extra meta box arguments.
    - `taxonomy` string
    - Taxonomy. Default `'post_tag'`.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#source)󠁿

    ```php
    function post_tags_meta_box( $post, $box ) {
    	$defaults = array( 'taxonomy' => 'post_tag' );
    	if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
    		$args = array();
    	} else {
    		$args = $box['args'];
    	}
    	$parsed_args           = wp_parse_args( $args, $defaults );
    	$tax_name              = esc_attr( $parsed_args['taxonomy'] );
    	$taxonomy              = get_taxonomy( $parsed_args['taxonomy'] );
    	$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
    	$comma                 = _x( ',', 'tag delimiter' );
    	$terms_to_edit         = get_terms_to_edit( $post->ID, $tax_name );
    	if ( ! is_string( $terms_to_edit ) ) {
    		$terms_to_edit = '';
    	}
    	?>
    <div class="tagsdiv" id="<?php echo $tax_name; ?>">
    	<div class="jaxtag">
    	<div class="nojs-tags hide-if-js">
    		<label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label>
    		<p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace( ',', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></p>
    	</div>
    	<?php if ( $user_can_assign_terms ) : ?>
    	<div class="ajaxtag hide-if-no-js">
    		<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
    		<input data-wp-taxonomy="<?php echo $tax_name; ?>" type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" />
    		<input type="button" class="button tagadd" value="<?php esc_attr_e( 'Add' ); ?>" />
    	</div>
    	<p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p>
    	<?php elseif ( empty( $terms_to_edit ) ) : ?>
    		<p><?php echo $taxonomy->labels->no_terms; ?></p>
    	<?php endif; ?>
    	</div>
    	<ul class="tagchecklist" role="list"></ul>
    </div>
    	<?php if ( $user_can_assign_terms ) : ?>
    <p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-<?php echo $tax_name; ?>" aria-expanded="false"><?php echo $taxonomy->labels->choose_from_most_used; ?></button></p>
    <?php endif; ?>
    	<?php
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/meta-boxes.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/meta-boxes.php#L572)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/meta-boxes.php#L572-L612)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#related)󠁿

| Uses | Description | 
| [get_terms_to_edit()](https://developer.wordpress.org/reference/functions/get_terms_to_edit/)`wp-admin/includes/taxonomy.php` |

Gets comma-separated list of terms available to edit for the given post ID.

  | 
| [esc_attr_e()](https://developer.wordpress.org/reference/functions/esc_attr_e/)`wp-includes/l10n.php` |

Displays translated text that has been escaped for safe use in an attribute.

  | 
| [disabled()](https://developer.wordpress.org/reference/functions/disabled/)`wp-includes/general-template.php` |

Outputs the HTML disabled attribute.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  | 
| [get_taxonomy()](https://developer.wordpress.org/reference/functions/get_taxonomy/)`wp-includes/taxonomy.php` |

Retrieves the taxonomy object of $taxonomy.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/post_tags_meta_box/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fpost_tags_meta_box%2F)
before being able to contribute a note or feedback.