-
Author
-
November 15, 2013 at 03:24 #6702hughmParticipant
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.November 17, 2013 at 02:29 #6782SQadminKeymasterHi,
That code should work but you have several templates for different post formats, content-post-format.phpHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 19, 2013 at 01:51 #6874hughmParticipantThe 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?
November 19, 2013 at 04:22 #6883hughmParticipantActually 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() );
November 19, 2013 at 14:11 #6914SQadminKeymasteryour 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 solutionNovember 19, 2013 at 15:56 #6928hughmParticipantThanks 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!
-
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.