WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Is it possible to get avatars from User Photo via userphoto_the_author_thu (10 posts)

  1. triphys
    Member
    Posted 2 years ago #

    Hi,

    I'm trying to get this plugin to work with User Photos since my users don't have gravatars for example.
    Now I'm using this code to get one users avatar:
    userphoto_the_author_thumbnail()

    Is there any possibility to have Co-Authors Plus take the thumbnails from there?
    And how?

    Thanks in advance!

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

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    Sorry, I'm not sure I understand the nature of your question. Is it the same as this other thread you've opened?

    If not, can you use Pastebin to share an example of the code you've prepared thus far?

  3. triphys
    Member
    Posted 2 years ago #

    Hi, and thanks for your response!

    Yes, it's regarding the same issue, I'm sorry for opening a new thread but the last post wasn't 100% accurate :)

    Okay, so basically when you usually add an avatar you use the get_avatar() tag, but since i use the plugin UserPhoto which allows me to upload an avatar in the admin menu for each author i'm using this code to generate an avatar in the post:
    <?php userphoto_the_author_thumbnail() ?>

    So I'm not 100 sure about this code, but i added an echo for the avatar like this:

    if ( class_exists( 'coauthors_plus' ) ) {
    	$co_authors = get_coauthors();
    	foreach ( $co_authors as $key => $co_author ) {
    		$co_author_classes = array(
    			'co-author-wrap',
    			'co-author-number-' . ( $key + 1 ),
    		);
    		echo '<div class="' . implode( ' ', $co_author_classes ) . '">';
    		echo '<h4 class="co-author-display-name">' . $co_author->display_name . '</h4>';
                    echo '<?php userphoto_the_author_thumbnail() ?>';
    		// Only print the description if the description exists
    		if ( $description = get_the_author_meta( 'description', $co_author->ID ) )
    			echo '<p class="co-author-bio">' . $description . '</p>';
    		echo '</div>';
    	}
    }

    Would that be correct?

    Before this implementation my code looked like this:

    <div class="byline">
    <p class="mypic"><?php userphoto_the_author_thumbnail() ?></p><p class="bylinetxt">Text: <?php the_author_posts_link(); ?></br>Published: <?php the_time('l, F j, Y') ?></p>
    </div>

    Thank you so much!

  4. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    You'll want something like:

    echo userphoto_thumbnail( $co_author );

  5. triphys
    Member
    Posted 2 years ago #

    Thanks for your reply, unfortunately it wont show the avatars quite yet. I think there might be something wrong with my code.

    ?php if ( class_exists( 'coauthors_plus' ) ) {
    	$co_authors = get_coauthors();
    	foreach ( $co_authors as $key => $co_author ) {
    		$co_author_classes = array(
    			'co-author-wrap',
    			'co-author-number-' . ( $key + 1 ),
    		);
    		echo '<div class="' . implode( ' ', $co_author_classes ) . '">';
    		echo '<h4 class="co-author-display-name">' . $co_author->display_name . '</h4>';
    		echo '<?php userphoto_the_author_thumbnail( $co_author ); ?>';
    		echo '</div>';
    	}
    } ?>

    It's only showing the names of the authors and no avatars.
    Any idea what it could be?

    Thanks again so much!

  6. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    Yes, this line:

    echo '<?php userphoto_the_author_thumbnail( $co_author ); ?>';

    should be:

    echo userphoto_thumbnail( $co_author );

    per my previous note.

  7. triphys
    Member
    Posted 2 years ago #

    Oh my god! It actually works! You're a saviour! Thank you so much for this!
    Last question and then you will be rid of me haha

    Is there a way to make the name link to the authorpage?

    Thanks again!

  8. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    Yes, you'll want to change:

    echo '<h4 class="co-author-display-name">' . $co_author->display_name . '</h4>';

    to:

    echo '<h4 class="co-author-display-name"><a href="' . get_author_posts_url( $co_author->ID . '">' . $co_author->display_name . '</a></h4>';

    This gets the posts URL for the author and wraps it around their name.

  9. triphys
    Member
    Posted 2 years ago #

    Thank you so much for all the help!
    Works perfectly.

  10. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    You're welcome :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic