How to Add Authors to WordPress Custom Post Types

WordPress developers use the “custom post type” feature for many different features, including some that are a million miles away from traditional “posts”.

For example, in WooCommerce, post types are used for Orders, Coupons, Products, and more.

Many of those post types are simplified versions of regular posts. They do not have Tags, Categories, Published Dates, Authors or other features.

We often have PublishPress users asking us how to add back some of these missing features. One of the most common requests is adding Authors.

It is possible to add back the Authors for almost any custom post type.

I'm going to use the example of adding the Author to WooCommerce coupons, but you could do the same thing for many other post types.

First, find the name of your custom post type. The easiest way to do that is to go to your WordPress admin area and look in the URL bar.

You are looking for the name after post_type=. In the image below, the name is shop_coupon.

In the image below, the name is product.

Now you know the name of your custom post type, you can add the code below to your theme's functions.php file. Change shop_coupon to the name of your post type.

function add_author_support_to_posts() {
   add_post_type_support( 'shop_coupon', 'author' ); 
}
add_action( 'init', 'add_author_support_to_posts' );

I have added Authors back to WooCommerce coupons. Inside each coupon, I will now see an “Authors” box:

This technique is part of two other WooCommerce tutorials: Control Who Can Access WooCommerce Coupons and also How to Add Authors to WooCommerce Products.


Steve Burge

Steve is the founder of PublishPress. Originally from the UK, he now lives in Sarasota in the USA. (P.S. This profile is generated by the PublishPress Authors plugin)

Leave a Reply

Your email address will not be published. Required fields are marked *

Professional publishing plugins for WordPress! Get PublishPress