Take your business to next level
Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.
To ensure accurate author performance data in the WP Statistics plugin, your post types need to support authors. This guide will help you enable author support for your custom post types.
register_post_type
When you register a post type using the register_post_type
function, you can specify the support for authors in the supports
parameter. Here’s how you can do it:
function my_custom_post_type() {
$args = array(
'label' => 'My Custom Post Type',
'public' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
// other arguments as needed
);
register_post_type( 'my_custom_post', $args );
}
add_action( 'init', 'my_custom_post_type' );
In this example, the supports
array includes 'author'
, ensuring that the post type supports author information.
If you have already registered a post type and need to add author support, you can use the add_post_type_support
function. Here’s an example:
function add_author_support_to_custom_post_type() {
add_post_type_support( 'my_custom_post', 'author' );
}
add_action( 'init', 'add_author_support_to_custom_post_type' );
This code snippet will add author support to the existing post type my_custom_post
.
By following these steps, you can ensure that your custom post types support authors, allowing the WP Statistics plugin to provide accurate author performance data.
For more details, you can refer to the official WordPress documentation for register_post_type
and add_post_type_support
.
Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.