Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Change author on custom post types WordPress



I need assistance with code to change the author on custom post types.

What I've found

This is in french and author says to use a filter

Thank you for checking.

Answers (6)


Cesar Contreras answers:

I think this is what you should do:

in order to add author support to a custom post type you need to added ‘author’ to the supports array when registering the post type:

'supports' => array('title', 'editor', 'thumbnail', 'comments', 'author'),

This will activate author box on the edit screen. After registering author to cpt you need to activate author from edit screen option ( top of the edit screen where you can enable/disable all metabox ) to display authorbox on the edit screen.

Here is the link to the documentation to create CPT:


mod mi answers:

Hi viradesign,

You don't mention how you register your custom post types but I'd strongly recommend the Custom Post Type UI plugin to save you time and effort from registering/editing your post types, custom taxonomies etc. You can enable disable options and update them via a simple UI. And it even has a feature to export the custom post types code if you'd prefer not to use it permanently.


Arnav Joy answers:

you have all posts created and want to change author of the all posts ?

Creativira comments:

Yes, all CPTs were created in a plugin called WP Customer Area with many addons.

Arnav Joy comments:

you have more then one cpt's ?

Creativira comments:

more than one CPT.


Luis Abarca answers:

If you want to update author for all items of a custom post type, you can run a query on your wp_posts table like below.


function update_authors_for_post_type( $author_id, $post_type ) {
global $wpdb;

$sql = 'UPDATE ' . $wpdb->prefix . ' SET post_author=%d';

$wpdb->query( $wpdb->prepare( $sql, $author_id ) );

update_authors_for_post_type( 1, 'your_custom_post_type );

Creativira comments:

Don't understand 'run a query'.

Luis Abarca comments:

Hi, it's a function to update post author on specific custom post type.

Example: Lets say, i want to assign all custom post types events to author Jhon with user ID 4.

Will call the function like below.

update_authors_for_post_type(4, 'events');


Francisco Javier Carazo Gil answers:

Good afternoon,

It seems that there is a filter called: cuar/private-content/files/register-post-type-args

Which is the one responsible of customize it.

It should be this one:

add_filter( 'cuar/private-content/files/register-post-type-args', 'set_authors_cpt' ) ;
function set_authors_cpt($args){
$args['supports'] = array( 'title', 'editor', 'author' );
return $args;

Creativira comments:

This shows a dropdown but with only admins as options. Would like to be able to choose other roles.


Mohammad Kashif Nadeem answers:

1. First you need to add this line into your custom post type code

"supports" => array( "title", "editor", "thumbnail", "excerpt", "trackbacks", "custom-fields", "comments", "revisions", "author", "page-attributes", "post-formats" ),

If you generated custom post type through wordpress plugin > Custom Post Type UI then you have to check Author check box. (please see screenshot section no.1)

2. Now go into your custom post type and click on the top right Button > Screen Option. In this pane please select Author. (please see screenshot section no.2)

3. Scroll down your page... on the button you would have a section Author. From here you can transfer authorship to any author. (please see screenshot section no.3)

Creativira comments:

Thank you. That doesn't help.

Mohammad Kashif Nadeem comments:

Good Luck
Have a Great Day!