They’re stored as terms. Each user has an associated term in the author taxonomy based on their username.
SO if my username was kylehardgrave, I would have a term for the author taxonomy called kylehardgrave. To add authors to posts, you just assign their associated terms to the post. If you’re going to do a bulk import, you can probably use the add_coauthors
function, e.g.
$post_id = 1;
$authors = array( 'kylehardgrave', 'anotheruser' );
global $coauthors_plus;
$coauthors_plus->add_coauthors( $post_id, $authors );
Hope that helps.
Hello, can you explain exactly how you’d use this function? I that you’d run something like the following:
function add_my_coathor() {
$post_id = 1;
$authors = array( 'kylehardgrave', 'anotheruser' );
global $coauthors_plus;
$coauthors_plus->add_coauthors( $post_id, $authors );
}
But where exactly do you run it? I’ve used the INSERT INTO
and WHERE
commands in MySQL to perform this kind of modification but I don’t understand how you’d run a PHP function. Do you just need to include it functions.php once?
Also, what if I want to remove the previous author first? By default, my bulk imported posts have an admin is the author.
Thanks Mohammad, that helps.
Jamil, you could either write a PHP script and run it by accessing it from the browser or by setting it up to run when you hit a button. You could also just use the info to help you write your SQL statements.