WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
No authors is displayed if co-author is installed after an article is written (1 post)

  1. korsani
    Member
    Posted 1 year ago #

    Hi,
    I use WP 3.5.1 and co-author 3.0.5 on a blog's small company, but with a lot of writters :)
    Thus, lots of article have been written BEFORE co-author was installed.
    In the admin page of WP, when I list all the articles, it displays author of an article only if the author has been assigned to it through co-authors frame (in the edit page of the article)
    In consequence, most of articles seems to have no author in the admin page of WP, but author appear on the blog.
    I wrote this patch, but I don't know if it's the best way to fix it :

    --- a/wp-content/plugins/co-authors-plus/template-tags.php
    +++ b/wp-content/plugins/co-authors-plus/template-tags.php
    @@ -3,8 +3,8 @@
     function get_coauthors( $post_id = 0, $args = array() ) {
            global $post, $post_ID, $coauthors_plus, $wpdb;
    
    -       $coauthors = array();
            $post_id = (int)$post_id;
    +       $coauthors = array();
            if ( !$post_id && $post_ID )
                    $post_id = $post_ID;
            if ( !$post_id && $post )
    @@ -32,7 +32,10 @@ function get_coauthors( $post_id = 0, $args = array() ) {
                            }
                            if ( !empty( $post_author ) )
                                    $coauthors[] = $post_author;
    -               } // the empty else case is because if we force guest authors, we don't ever care what value wp_posts.post_author has.
    +               }       // the empty else case is because if we force guest authors, we don't ever care what value wp_posts.post_author has.
    +       // No co-authors found ? Get the legacy one (ggu@octo.com)
    +       if (0 == count($coauthors) )
    +               $coauthors[]=get_userdata($wpdb->get_var( $wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d", $post_id ) ));
            }
            return $coauthors;
     }
    @@ -489,4 +492,4 @@ function coauthors_wp_list_authors( $args = array() ) {
            if ( ! $args['echo'] )
                    return $return;
            echo $return;
    -}
    \ No newline at end of file
    +}

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic