Support » Plugin: Co-Authors Plus » Retrieving the Co Authors information on a single post page

  • Resolved michael.oeser

    (@michaeloeser-1)


    I´m trying to display the googleplus info of a specific author in the header of a single post page. I´m doing the exact same in th ehead of an author archive by using the codesniped from the codex:

    <?php $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); // get the info about the current author ?>
    
    <?php echo $curauth->googleplus; ?>

    But this doesn´t work on a single post page. Is that related to Co-Authors Plus? I assume it is. Do I need to do something different to retireve the $curauth information?

    Thanks in advance

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Hand Built

    What happens if you use the following instead in your single.php?

    <?php $curauth = get_user_by( 'id', get_queried_object()->post_author ); // get the info about the current author ?>
    
    <?php echo $curauth->googleplus; ?>

    If that doesn’t work, does the first code snippet you’ve specified work when Co-Authors Plus is disabled? Are you assigning a WordPress user to the post, or a guest author profile?

    Works perfect. Thanks Daniel.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieving the Co Authors information on a single post page’ is closed to new replies.