Add Built-in WordPress Tags to a Custom Post Type

When you need tag-like classification for a custom post type, the instinct is often to register a new custom taxonomy. But if you want to reuse the same tag pool that regular posts use — including the ability to create tags directly from the post-editing screen and have them appear on the shared tag archive pages — you can simply attach the built-in post_tag taxonomy to your CPT.

Problem: A custom post type was registered without taxonomy support, and editors now need to tag posts using the same global tag vocabulary as standard WordPress posts — without creating a separate custom taxonomy.

Solution: Add 'taxonomies' => ['post_tag'] to the arguments array when calling register_post_type(), or register the association after the fact with register_taxonomy_for_object_type('post_tag', 'your-cpt') in an init hook.

Step 1. Add 'taxonomies' => [ 'post_tag' ] to the arguments when registering your custom post type:

<?php
add_action( 'init', 'register_media_post_type' );

function register_media_post_type() {
    $args = [
        'label'        => __( 'Media Posts', 'theme-name' ),
        'supports'     => [ 'title', 'editor', 'excerpt', 'thumbnail' ],
        'taxonomies'   => [ 'post_tag' ], // share the built-in tags taxonomy
        'show_in_rest' => true,
        'public'       => true,
        'has_archive'  => true,
        'menu_icon'    => 'dashicons-media-video',
        'rewrite'      => [ 'slug' => 'media', 'with_front' => true ],
    ];

    register_post_type( 'media-post', $args );
}

After this, the Tags meta box appears on the Media Post editing screen and you can assign existing tags or create new ones exactly as you would for a regular post.

Step 2. By default, the tag archive page (/tag/some-tag/) only queries the post post type. Use pre_get_posts to include your CPT in the main query on tag archive pages:

<?php
add_action( 'pre_get_posts', 'include_cpt_in_tag_archives' );

function include_cpt_in_tag_archives( $query ) {
    if ( ! is_admin() && $query->is_tag() && $query->is_main_query() ) {
        $query->set( 'post_type', [ 'post', 'media-post' ] );
    }
}

The same pattern applies for category archives: replace 'taxonomies' => ['post_tag'] with 'taxonomies' => ['category'] in the registration arguments, and use $query->is_category() in the pre_get_posts filter.

NOTE: Sharing a built-in taxonomy couples your CPT tightly to the default tag/category pool. If you ever need separate term vocabularies per post type — for example, different tag sets with different slugs — registering a dedicated custom taxonomy is the cleaner choice.