The post_tags_meta_box() WordPress PHP function displays post tags form fields.
Usage
post_tags_meta_box($post, $box);
Parameters
$post
(WP_Post): Required. The current post object.$box
(array): Required. 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’.
More information
See WordPress Developer Resources: post_tags_meta_box
Examples
Displaying Post Tags Meta Box
function display_post_tags_meta_box() { $post = get_post(); $box = array( 'id' => 'tagsdiv-post_tag', 'title' => 'Tags', 'callback' => 'post_tags_meta_box', 'args' => array(), 'taxonomy' => 'post_tag' ); post_tags_meta_box($post, $box); }
Displaying a Custom Taxonomy Meta Box
function display_custom_taxonomy_meta_box() { $post = get_post(); $box = array( 'id' => 'tagsdiv-custom_taxonomy', 'title' => 'Custom Taxonomy', 'callback' => 'post_tags_meta_box', 'args' => array(), 'taxonomy' => 'custom_taxonomy' ); post_tags_meta_box($post, $box); }
Adding Extra Arguments to the Meta Box
function display_meta_box_with_extra_args() { $post = get_post(); $box = array( 'id' => 'tagsdiv-extra_args', 'title' => 'Tags with Extra Args', 'callback' => 'post_tags_meta_box', 'args' => array('show_option_all' => 'Show All Tags'), 'taxonomy' => 'post_tag' ); post_tags_meta_box($post, $box); }
Displaying Meta Box with a Custom Callback
function custom_callback($post, $box) { echo 'This is a custom callback!'; } function display_meta_box_with_custom_callback() { $post = get_post(); $box = array( 'id' => 'tagsdiv-custom_callback', 'title' => 'Custom Callback', 'callback' => 'custom_callback', 'args' => array(), 'taxonomy' => 'post_tag' ); post_tags_meta_box($post, $box); }
Displaying Multiple Taxonomies in Separate Meta Boxes
function display_multiple_taxonomies_meta_boxes() { $post = get_post(); $taxonomies = array('post_tag', 'custom_taxonomy'); foreach ($taxonomies as $taxonomy) { $box = array( 'id' => 'tagsdiv-' . $taxonomy, 'title' => ucfirst($taxonomy), 'callback' => 'post_tags_meta_box', 'args' => array(), 'taxonomy' => $taxonomy ); post_tags_meta_box($post, $box); } }