4

I've built a marketplace-type site that lets different users post custom listings to the site.

I want to use the WP backend to administer these listings with my admin account. The custom post types are displayed much like normal posts there.

The problem is that the post author isn't shown. I googled the issue and quickly found that adding "supports" => array( "title", "editor", "author" ) to the $args for register_post_type() adds a column showing the author to the listings of all custom post items.

However, I'm unsure how to add a box displaying the author in the edit screen where the editor and other detailed information about the post shows. As is I just have the box with the publishing information and one for the custom post type's taxonomies.

How would I go about having the post's author displayed there too? I'm really a bit lost on this and couldn't find anything on google.

2 Answers 2

4

You can achieve this by using the add_post_type_support function as described here: https://codex.wordpress.org/Function_Reference/add_post_type_support.

This code should work:

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

It can be added in your theme's function.php file.

1

If you are using the plugin CPT UI you can simply edit the custom post type there.

  1. navigate to CPT UI in admin section

  2. select the post type you want to add the 'author' feature to

  3. scroll down almost to the bottom and in the 'Supports (Add support for various available post editor features on the right...)' and in the checkbox to the right make sure that the checkbox for 'author' is checked.

You may then need to refresh your cache but you'll see the 'author' field appear next to each custom post type in the admin screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.