CMS Development

ldiethel
Participant

How to add an author name to blog posts

Hi, I am trying to edit my blog template to include the author name alongside their avatar/photo. My template already has this 

<div class="blog-post__author">
{# <a href="{{ blog_author_url(group.id, content.blog_post_author.slug) }}">
{{ content.blog_post_author.display_name }}

 

but no name shows up. Where and what do I need to change to add the name?

0 Upvotes
4 Replies 4
himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

How to add an author name to blog posts

Hello @ldiethel 

you need to modify the code you have shared.

<div class="blog-post__author">
  <a href="{{ blog_author_url(group.id, content.blog_post_author.slug) }}">
    <img src="{{ content.blog_post_author.profile_photo.url }}" alt="{{ content.blog_post_author.display_name }}" class="blog-post__author-avatar">
  </a>
  <span class="blog-post__author-name">{{ content.blog_post_author.display_name }}</span>
</div>

 

In the code above, we added a span element with the class blog-post__author-name to display the author's name. You can customize the span element's style to match your blog's design.

Also, make sure that the content.blog_post_author object contains a valid author name. If the author name is missing, it won't appear on the blog post.

Thanks & Regards 
Himanshu Rauthan

Digital Marketing & Inbound Expert In Growth Hacking Technology
0 Upvotes
ldiethel
Participant

How to add an author name to blog posts

Thanks, Himanshu!! 

 

When I add the code you supplied, I get this: 

 

Screenshot 2023-03-14 at 7.18.51 AM.png

Am I doing something wrong or adding this snippet in the wrong spot? 

0 Upvotes
himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

How to add an author name to blog posts

Hello @ldiethel 

Make sure that you add the code in the correct place in your blog post template. The code snippet should be added within the existing div element with the class "blog-post__author".

Try adding the code snippet just after the closing tag for the anchor element (</a>), as shown in the modified code I provided earlier.

Also, make sure that you properly closed all the HTML tags in your template before adding the new code. Any unclosed tag can cause unexpected formatting issues.

If you're still having trouble, please share more details or the code of your blog post template, and I'll try to help you better.

Digital Marketing & Inbound Expert In Growth Hacking Technology
0 Upvotes
ldiethel
Participant

How to add an author name to blog posts

Thanks for your reply, I feel like I'm getting close! here is where I'm adding it, but still having the same issue as above.  I appreciate your help! 

 

Screenshot 2023-03-15 at 7.54.07 AM.png

0 Upvotes