Community Forums › Forums › Archived Forums › General Discussion › How to display the profile picture on the homepage
Tagged: author archive, author avatar
- This topic has 6 replies, 2 voices, and was last updated 10 years, 1 month ago by
riseUp.
-
AuthorPosts
-
March 1, 2016 at 10:47 pm #180404
riseUp
MemberHello,
Does anybody know how to display the profile picture/avatar for each post on the homepage? I am noticing that it does not show on the homepage for each post. However, when you click on a post, you can see the profile picture/avatar.
Please excuse the messiness of the homepage as I am doing some trial and error on the whole Genesis structure. Thanks.
http://www.ymphony.comMarch 2, 2016 at 4:03 am #180416Brad Dalton
ParticipantAre you referring to this post? http://www.studiopress.community/topic/how-to-display-author-photo-next-to-the-post-on-the-homepage/
March 3, 2016 at 8:29 pm #180601riseUp
MemberThat's right. I'm still trying to figure this one out.
I am using the following code to display the avatar on the homepage for each post:
function wpsites_post_author_avatars() {
echo get_avatar(get_the_author_meta('email'), 300);
}The above code allows me to show the avatar on the homepage for each post. However, I can't seem to display the avatar above the title and centered based upon the following:
add_action( 'genesis_entry_header', 'bg_entry_gravatar', 7 );
function bg_entry_gravatar() {
if ( is_singular( 'post' ) ) {
echo '<div class="entry-avatar">';
echo get_avatar( get_the_author_meta( 'user_email' ), 240 );
echo '</div>';
}
}So, I attempted to "merge" the BG code into your code, but with no success. What do you think?
March 4, 2016 at 3:51 am #180628Brad Dalton
ParticipantHere's a few things you can try:
1. You could change the hook to
genesis_before_entry
or
2. Change the 3rd parameter to 1
or
3. Filter the entry title
or
4. Use CSS to position the image before the entry title
Another option is to look for a theme which already includes the avatar before the title and see how its done.
March 4, 2016 at 6:18 am #180639riseUp
MemberHi.
I was able to place the avatar above the title which is great. I was able to tweak your code as the following:
function wpsites_post_author_avatars() {
echo get_avatar(get_the_author_meta('email'), 300);
}add_action('genesis_entry_header', 'wpsites_post_author_avatars', 7);
I added a "7" to the their area of add_action.
How would I be able to "center" the image? The CSS code that I have is:
.entry-header .avatar {
border: 5px solid #f5f5f5;
border-radius: 50%;
float: none;
height: 120px;
margin-bottom: 20px;
text-align: center;
width: 120px;I tried tinkering with the text-align: center here and there but with no avail. Thanks.
March 4, 2016 at 7:01 am #180642Brad Dalton
ParticipantMarch 4, 2016 at 7:56 pm #180679riseUp
MemberThat worked. Thank you!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.