Community Forums › Forums › Archived Forums › General Discussion › Gravatar Before Post title
Tagged: gravatar, post title
- This topic has 8 replies, 2 voices, and was last updated 11 years ago by Brad Dalton.
-
AuthorPosts
-
April 26, 2013 at 9:45 am #37862sterman7Member
There are some threads that address this but I am having no luck. So, to help anyone else out as well as myself. Can some one drop some knowledge how to simply add a gravatar to the before post title? Please do not point me to the Bill Erickson post it is not particularly helpful for non coders like myself. I am happy to mess with the functions.php file only if I know exactly what I am doing. I have enough knowledge just to be dangerous and since the Erickson write up is not really for Genesis I find it not useful. Any help would be greatly appreciated by me and anyone that follows in the future.
April 26, 2013 at 11:37 am #37882Brad DaltonParticipantI've written some code for this which includes the after title hook which you can simply change to the before post title hook.
Can't get into Github gists at the moment because of internet problems but will post the code as soon as i can.
April 26, 2013 at 11:41 am #37883sterman7MemberThanks for the reply.
April 26, 2013 at 12:13 pm #37888Brad DaltonParticipantApril 26, 2013 at 12:56 pm #37903sterman7MemberBrad,
Thanks. Two follow on questions if you do not mind.
1. If I want the avatars to appear before the post title on the home page would it be as simple as editing your code by adding
if (is_home() after the if (is_single())???2. Is there any way to get the avatar on the same line as the title versus the line above? Reference any post on this site - http://readingthecompass.com
Thanks again!!
April 26, 2013 at 1:07 pm #37904sterman7MemberDoin' my leg work man. If figured out how to nest a second conditional for the answer to my first question but I am afraid I cannot come up with how to move the image onto the same line as the actual title on both the home and single pages. ??
The answer to my first question for future readers is:
if (is_home() || is_single())
April 26, 2013 at 1:38 pm #37907sterman7MemberStill doin' my leg work and got the images in line with the title by:
I updates the .post image line of code in my css style sheet to look like this:
.post-image {
background-color: #f5f5f5;
border: 1px solid #ddd;
padding: 4px;
float:left;
display: inline;
margin-right: 0.5em;
}Much love to Brad for doing the heavy lifting.
April 26, 2013 at 1:50 pm #37909sterman7MemberSo for anyone that wants to put a gravatar next to their post titles on both their home page and the posts themselves here is what I did thanks to Brad. Keep in mind I have properly set up my gravatar account to work with wordpress.
in my functions.php file I added:
/** * @author Brad Dalton - WP Sites * * @link http://wpsites.net/web-design/display-post-author-avatar-byline/ */ function wpsites_single_post_author_avatars() { if (is_home() || is_single()) { echo get_avatar(get_the_author_id(), 40); } } add_action('genesis_before_post_title', 'wpsites_single_post_author_avatars');
Then I did the following to my style sheet under the IMAGES headline find the .post-image details and update them:.post-image { background-color: #f5f5f5; border: 1px solid #ddd; padding: 4px; float:left; display: inline; margin-right: 0.5em;
April 26, 2013 at 8:28 pm #37990Brad DaltonParticipantGood stuff. Just woke up but see you have nailed it with the PHP. Not sure about the CSS but it seems to work for you.
See you learn't a lot about conditional tags and custom functions which will give you alot of confidence moving forward.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.