Support » Plugins » [Plugin: Co-Authors Plus] coauthors_wp_list_authors bug?

  • Hello

    Pleased to see the development of this plugin

    Though the coauthors_wp_list_authors tag appears to have a similar problem as the original co-authors plugin. That is, users who don’t have a post as a first author, but only as a co-author, do not appear with links when listed via the coauthors_wp_list_authors tag.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi snowcrash,

    Thanks for your note. Is this happening in any specific contexts (e.g. on particular posts or archive pages) or any time the tag is used? I know that there is an issue on author pages with some of the tags, and I should have a fix coming out soon.

    Hi batmoo

    I’ve used this in my own template page (called it contributor.php), where I simply include the coauthors_wp_list_authors tag, for example:

    <?php if(function_exists('coauthors_posts_links'))
    			wp_list_authors('hide_empty=1'); ?>

    look forward to a fix
    many thanks

    The bug is inside this sql statement:

    $author_count = array();
     $sql = "SELECT DISTINCT
     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

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

    @moskjis: That information appears to be outdated. Do you (or does anyone else) know a solution for the most recent version of the plugin?

    This is the SQL code which isn’t working correctly:

    $query  = "SELECT DISTINCT $wpdb->users.ID AS post_author, $wpdb-> AS user_name, $wpdb->term_taxonomy.count AS count";
    	$query .= " FROM $wpdb->posts";
    	$query .= " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
    	$query .= " INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
    	$query .= " INNER JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)";
    	$query .= " INNER JOIN $wpdb->users ON ($wpdb-> = $wpdb->users.user_login)";
    	$query .= " WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' );
    	$query .= " AND $wpdb->term_taxonomy.taxonomy = '$coauthors_plus->coauthor_taxonomy'";
    	$query .= " GROUP BY post_author";

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Co-Authors Plus] coauthors_wp_list_authors bug?’ is closed to new replies.