Content Types Overview Screen
Adds Tools > Content Types, a table of every registered post type and taxonomy with its labels, visibility, archive, REST base, URL slug and item count.
Opens WPIDE on
Code
add_action( 'admin_menu', function () {
add_management_page( 'Content Types', 'Content Types', 'manage_options', 'wpide-content-types', function () {
$yes = function ( $value ) {
return $value ? '✓' : '—';
};
echo '<div class="wrap"><h1>Content Types</h1><h2>Post types</h2><table class="widefat striped"><thead><tr><th>Name</th><th>Label</th><th>Public</th><th>Archive</th><th>REST base</th><th>URL slug</th><th>Published</th></tr></thead><tbody>';
foreach ( get_post_types( array(), 'objects' ) as $type ) {
$count = wp_count_posts( $type->name );
printf(
'<tr><td><code>%1$s</code></td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></tr>',
esc_html( $type->name ),
esc_html( $type->label ),
esc_html( $yes( $type->public ) ),
esc_html( $type->has_archive ? ( is_string( $type->has_archive ) ? $type->has_archive : '✓' ) : '—' ),
esc_html( $type->show_in_rest ? ( $type->rest_base ? $type->rest_base : $type->name ) : '—' ),
esc_html( is_array( $type->rewrite ) ? ( $type->rewrite['slug'] ?? '' ) : '—' ),
esc_html( number_format_i18n( isset( $count->publish ) ? (int) $count->publish : 0 ) )
);
}
echo '</tbody></table><h2>Taxonomies</h2><table class="widefat striped"><thead><tr><th>Name</th><th>Label</th><th>Post types</th><th>Hierarchical</th><th>Public</th><th>REST base</th><th>URL slug</th></tr></thead><tbody>';
foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
printf(
'<tr><td><code>%1$s</code></td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></tr>',
esc_html( $taxonomy->name ),
esc_html( $taxonomy->label ),
esc_html( implode( ', ', (array) $taxonomy->object_type ) ),
esc_html( $yes( $taxonomy->hierarchical ) ),
esc_html( $yes( $taxonomy->public ) ),
esc_html( $taxonomy->show_in_rest ? ( $taxonomy->rest_base ? $taxonomy->rest_base : $taxonomy->name ) : '—' ),
esc_html( is_array( $taxonomy->rewrite ) ? ( $taxonomy->rewrite['slug'] ?? '' ) : '—' )
);
}
echo '</tbody></table></div>';
} );
} );
Notes
Handy for finding the internal names other snippets ask for.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.