WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Retrieving the Co Authors information on a single post page (3 posts)

  1. michael.oeser
    Member
    Posted 1 year ago #

    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/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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?

  3. michael.oeser
    Member
    Posted 1 year ago #

    Works perfect. Thanks Daniel.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.