Gravatar Before Post title

Community Forums Forums General Discussion Gravatar Before Post title

This topic is: not resolved

This topic contains 8 replies, has 2 voices, and was last updated by  braddalton 1 year, 5 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #37862

    sterman7
    Participant
    Post count: 22

    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.

     

     

    http://marketandeconomy.com
    #37882

    braddalton
    Participant
    Post count: 10217

    I’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.


    #37883

    sterman7
    Participant
    Post count: 22

    Thanks for the reply.

    #37888

    braddalton
    Participant
    Post count: 10217
    #37903

    sterman7
    Participant
    Post count: 22

    Brad,

    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!!

     

    #37904

    sterman7
    Participant
    Post count: 22

    Doin’ 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())

    #37907

    sterman7
    Participant
    Post count: 22

    Still 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.

    #37909

    sterman7
    Participant
    Post count: 22

    So 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;
     
    #37990

    braddalton
    Participant
    Post count: 10217

    Good 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.


Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.