This topic has 5 replies, 2 voices, and was last updated 11 years by hughm.

  • Author
  • #6702
     hughm
    Participant

    I am trying to add an avatar to the main blog posts and have it link back to the member profile page (like the avatar in [Kleo] Recent Posts widget.
    I copied the single post template (Sweetdate/content.php) to my child theme and lifted some code from your Recent Posts widget and put it into content.php but am missing something.

    COPY CODE
    <h2 class="article-title"><a href="<?php the_permalink(); ?>"><?php echo get_avatar( get_the_author_meta("ID"), 32 ); ?></a>
                  <a href="<?php echo get_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

    Could you help me to link the avatar back to the profile.
    Thanks very much.

    #6782
     SQadmin
    Keymaster

    Hi,
    That code should work but you have several templates for different post formats, content-post-format.php

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6874
     hughm
    Participant

    The above code does work and displays the user avatar nicely but the link from the avatar image does not work. When you click it does not take you to the profile page. Any ideas why?

    #6883
     hughm
    Participant

    Actually decided on a better way. I copied the function sweetdate_entry_meta from the Sweetdate functions.php file into the sweetdate-child/functions.php file. I rearranged the category list items to make the author display first before the date, category, and comments links. What makes sense to me is to have the author link go to the author/member profile (bridging the gap between wordpress and buddypress).

    I found some code to accomplish this in the BP default theme but couldn’t get it to work. Mind taking a look?

    COPY CODE
    
    $author = sprintf( <a href="%1$s" title="%2$s" rel="author">%3$s</a>,
    		esc_url( bp_core_get_userlink( $post->post_author ) ),
    		esc_attr( sprintf( __( View all posts by %s, kleo_framework ), get_the_author() ) ),
    		get_the_author()
    	);
    
    #6914
     SQadmin
    Keymaster

    your code has lots of errors

    COPY CODE
    
    $author = sprintf( '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
            esc_url( bp_core_get_user_domain( get_the_author_meta("ID") ) ),
            esc_attr( sprintf( __( "View all posts by %s", "kleo_framework" ), get_the_author() ) ),
            get_avatar( get_the_author_meta("ID"), 32 )
        );
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6928
     hughm
    Participant

    Thanks a lot. That works great!

    Yes, lots of errors. I couldn’t get the code to show correctly so I ended up removing the apostrophes that were getting converted to the html values for some reason. In any case, all sorted. Thanks again for the great support and the great theme. Awesome!

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

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?