Maris Svirksts

Sandbox for those few moments without coding
Sandbox for those few moments without coding

Co-authors author list bug

There is a bug inside Co Authors and Co Authors Plus plugin, coauthors_wp_list_authors function, where co authors without their own posts doesn't get links to their posts: http://wordpress.org/support/topic/275644

The bug is inside this sql statement:

$author_count = array();
 $sql = "SELECT DISTINCT
 p1.post_author,
 (COUNT(ID)+(SELECT COUNT(*)
 FROM $wpdb->posts p2, $wpdb->postmeta pm
 WHERE p2.ID = pm.post_id
 AND pm.meta_key = '_coauthor'
 AND pm.meta_value = p1.post_author)
 ) AS count
 FROM $wpdb->posts p1
 WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . "
 GROUP BY post_author";

To fix it I changed the lines above (coauthors.php file, lines 455 till 466 from Co Authors Plus plugin) to this:

foreach ( (array) $authors as $author ) {
 $sql = "SELECT count(*) AS count FROM $wpdb->posts p1, $wpdb->postmeta pm WHERE p1.ID = pm.post_id AND pm.meta_key = '_coauthor' AND pm.meta_value = '" . $author->ID . "' AND p1.post_status = 'publish' OR p1.post_author = '" . $author->ID . "' AND p1.post_status = 'publish'";

And add '}' symbol right after line 508.

Now, this is definitely not the best variant as it makes an sql query for each author, but - it works. One can see it in action at darkmatter101.org.

If you don't want to dive into your plugin file, to fix this: Co Authors Plus modified plugin download link.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email

One Response to “Co-authors author list bug”

    Leave a Reply

    Search