WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Author page shows repeating posts (28 posts)

  1. rzeisler
    Member
    Posted 1 year ago #

    I just installed 3.0.4 and am having a problem with the author archive page. When the plugin is activated, I see the first post repeated multiple times:

    http://img687.imageshack.us/img687/1060/coauthorsplusactivated.jpg

    When I deactivate the plugin, I see each of the authors posts:

    http://img846.imageshack.us/img846/4554/coauthorsplusdeactivate.jpg

    http://wordpress.org/extend/plugins/co-authors-plus/

  2. justkristin
    Member
    Posted 1 year ago #

  3. rzeisler
    Member
    Posted 1 year ago #

    I applied the code fix reference at http://pastebin.com/Lb89JP17 on the above mentioned link. This was a replacement of posts_join_filter function. I saw no difference in the way the author archive page was displayed. It still is repeating the author's same post multiple times. When I deactive the plugin, I see each of the author's individual posts.

    Any other suggestions?

  4. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    @rzeisler did you edit the user's user_nicename value by chance? Is this problem happening with different users?

  5. rzeisler
    Member
    Posted 1 year ago #

    Is the user_nicename the field that is displayed as Nickname under Edit User?

    If the answer is yes, then yes, most user's Nicknames are changed to be their name followed by a title (like 'John Smith, Chief Executive Officer, XYZ Company'). and then this is used as the 'Display name publicly as' setting.

    Are you using this field as a 'key' instead of the user_id?

    Are you assuming that the Username and Nickname are always equal?

  6. rzeisler
    Member
    Posted 1 year ago #

    You also asked if this problem was happening with different users. The answer is yes, it is happening to different users, but I only included the one example above.

  7. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Can you see if the discussion in this thread is relevant to your issue?

  8. rzeisler
    Member
    Posted 1 year ago #

    Read a little bit of the discussion thread. I used mysql to dump the wp_user table, displaying user_login and user_nicename fields. Rarely do they ever match. Many of the user_login values are for example 'John.Smith' and the user_nicename becomes 'john-smith'.

    I don't know if case matters in your comparison, but anytime a user's user_login has uppercase characters, the user_nicename replaces it with lowercase characters.

    Any blank character (space) is allowed in user_login but is replaced with a dash in the user_nicename.

    Any period is allowed in the user_login but is replaced with a dash in the user_nicename.

    I did not use a plugin that allowed me to modify the user_nicename. They are what the system created.

  9. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Odd. It doesn't sound like this is that same issue. Can you provide the code you're using to output the author profile page?

  10. rzeisler
    Member
    Posted 1 year ago #

    This is the _post.php file from my theme:

    http://pastebin.com/gpaT79gX

    Is this what you are looking for?

  11. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Do you have an author.php file?

  12. WPYoda
    Member
    Posted 1 year ago #

    Very interesting. On my website, I've noticed that only the authors who don't share an article with someone else have repeating posts on their author page. I tested my hypothesis by adding a second author to one of the single-author posts and that fixed my problem.

    I'm still very confused and have no idea why this worked. Hopefully, this provides you guys with some sort of clue.

  13. rzeisler
    Member
    Posted 1 year ago #

    @Daniel Bachhuber - my theme does not have an author.php file.

  14. rzeisler
    Member
    Posted 1 year ago #

    Based on @Wp Yoda's comment, I added another author to a post and now the author page for both authors displays properly. The author with multiple posts now shows all the different posts. The author that I added only shows the one post (that author previously had zero posts).

    Then I went to another post for a different author. I verified that on the author page it showed the first article repeating. I then edited the post and clicked the Update button (changed nothing in the post). Then I viewed the post and click on the author (coauthor_post_links) link and I see all the posts for that author.

    I am not sure what is changing when I click the Update button, but something is "fixing" the problem that is causing the repeating posts on the author page.

    Thoughts?

  15. rzeisler
    Member
    Posted 1 year ago #

    I backed out the code fix referenced at http://pastebin.com/Lb89JP17 that I had previously installed. I then updated (no changes) a post for an author that was showing repeating posts for the same article. When I went to the author page (by clicking on the coauthor_post_links) all was good, no repeating/duplicate posts.

    Each time I update a post (making no changes), the author page for that author will now show their posts correctly.

    It appears that something is going on when you update a post that fixes the problem. Is there any way to do this in mass?

  16. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Co-Authors Plus uses a custom taxonomy behind the scenes to associate bylines with posts. I suspect what's happening is that you don't have terms for each author and this is causing some bugginess. I'll see if I can track it down.

    In the interim, hitting Update on one post per author should do the trick. There's a wp-cli command you can use instead if you're familiar.

  17. rzeisler
    Member
    Posted 1 year ago #

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

  18. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

  19. rzeisler
    Member
    Posted 1 year ago #

    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.

  20. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

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

  21. rzeisler
    Member
    Posted 1 year ago #

    106 authors

  22. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

  23. rzeisler
    Member
    Posted 1 year ago #

    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.

  24. rzeisler
    Member
    Posted 1 year ago #

    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.

  25. rzeisler
    Member
    Posted 1 year ago #

    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.

  26. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

  27. WPYoda
    Member
    Posted 1 year ago #

    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?

  28. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.