# Topics Taxonomy Shared by Posts and Pages

> Registers a "Topics" taxonomy used by both posts and pages, so related content of either kind can be grouped and listed together.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: taxonomies, topics, pages
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tax-shared-topics/

## Code

```php
add_action( 'init', function () {
    register_taxonomy( 'content_topic', array( 'post', 'page' ), array(
        'labels'            => array(
            'name'          => 'Topics',
            'singular_name' => 'Topic',
            'menu_name'     => 'Topics',
            'all_items'     => 'All Topics',
            'edit_item'     => 'Edit Topic',
            'view_item'     => 'View Topic',
            'update_item'   => 'Update Topic',
            'add_new_item'  => 'Add New Topic',
            'new_item_name' => 'New Topic Name',
            'search_items'  => 'Search Topics',
            'not_found'     => 'No topics found.',
            'parent_item'   => 'Parent Topic',
        ),
        'hierarchical'      => true,
        'public'            => true,
        'rewrite'           => array( 'slug' => 'topic', 'with_front' => false ),
        'show_admin_column' => true,
        'show_in_rest'      => true,
    ) );
} );
```

## Notes

Add your custom post types to the list to group them too.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Topics Taxonomy Shared by Posts and Pages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
