Viewing 12 replies - 16 through 27 (of 27 total)
  • Thread Starter rzeisler

    (@rzeisler)

    What does “you don’t have terms for each author” mean? Is this something I can see in SQL or in the UI?

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    There isn’t a UI for it, but you can look at your wp_terms or similar table to see a bunch of rows that correlate with your authors.

    Thread Starter rzeisler

    (@rzeisler)

    I took a look at wp_terms. Toward the bottom of the table, I see entries for several authors (the ones I did the update post on). They look something like this:

    name slug
    john.smith cap-john-smith

    I assume that the name is the user_login since it can includes uppercase letters, periods, and spaces, unlike the user_nicename.

    The slug is cap- plus the user_nicename because the end of the cap- has been normalized to not include uppercase or special characters.

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    Yep, good sleuthing. How many authors do you need to create terms for?

    Thread Starter rzeisler

    (@rzeisler)

    106 authors

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    Try adding this to your theme’s functions.php and hitting refresh in the admin (or a few times if it times out):

    add_action( 'admin_init', 'dbx_update_author_terms' );
    function dbx_update_author_terms() {
    	global $coauthors_plus;
    
    	$users = get_users();
    	if ( ! $users )
    		return;
    
    	foreach( $users as $user ) {
    		$coauthors_plus->update_author_term( $user );
    	}
    }

    It’s basically creating a term for each author if the term doesn’t yet exist. You’ll want to remove the code snippet as soon as you’re done.

    Thread Starter rzeisler

    (@rzeisler)

    I will go try the above code now. You could use the register_activation_hook function to call this code when the plugin is activated.

    Thread Starter rzeisler

    (@rzeisler)

    The above code did exactly what I would expect it to do. It added the missing entries to wp_terms and all the author pages now work. This was about 90 additional entries. Much nicer then if I had to find all the appropriate posts and click update on each one.

    I am going to do a little more testing to make sure that new users I create are added to wp_terms either when I add the user or the first time I add them as a coauthor in a post.

    Thread Starter rzeisler

    (@rzeisler)

    I installed the plugin in production, run the script to popuplate wp_terms, and then added the coauthors to all the posts that required them.

    I did notice that when I installed the plugin (maybe after the script ran), all the Posts counts in Users were zeros, instead of the actual number of posts the user had authored. As I updated the coauthors, then the Posts counts were updated to the correct number. This required me to go to at least one post for any author who wasn’t used as a coauthor and click Update to have the Posts count show up in Users.

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    I did notice that when I installed the plugin (maybe after the script ran), all the Posts counts in Users were zeros, instead of the actual number of posts the user had authored. As I updated the coauthors, then the Posts counts were updated to the correct number.

    Odd. Sorry about that. I’ll take a look.

    Will this fix prompt a new version of Co-Authors Plus or will one have to do the fix by hand? Also, what could one have done to avoid this from happening in the first place?

    Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    The duplicate posts should is fixed and will be available in the next version. You can download the development version if you need a quicker fix.

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘Author page shows repeating posts’ is closed to new replies.