Authors are not displayed on the post card

First of all thanks to forum members for the support! It really helps me to start my journey with Ghost.

I want authors to be displayed on the post card. I made a simple modification in the post-card.hbs for that purpose:

 <footer class="post-card-meta">
            <time class="post-card-meta-date" datetime="{{date format="YYYY-MM-DD"}}">{{date}}</time>
            <span class="gh-card-author">{{#foreach authors}}{{#if @first}}{{name}}{{else}}, {{name}}{{/if}}{{/foreach}}</span>

The author name on the homepage is displayed properly, but in the read more section on the article page it is hidden. It does not even show up in the web inspector, so I guess it’s a back-end problem. Is it a glitch?

That’s probably produced by a partial other than the one you edited, or the one you edited has different output in different contexts. I’d check your partials/ folder for something like related-posts.hbs. That’s a guess at the name, but if you look towards the bottom of post.hbs, you’ll be able to figure out exactly how your theme is creating that section, and then you’ll know where to patch in the authors code you wrote above.

@Cathy_Sarisky thanks for the reply. The post.hbs uses post-card.hbs, exactly the one I edited. I have no more partials related to posts, as I’m using a default Casper theme. Here is the code of the read more section at the bottom of the post.hbs:

{{!-- Read more links, just above the footer --}}
{{#if @custom.show_recent_posts_footer}}
    {{!-- The {#get} helper below fetches some of the latest posts here
    so that people have something else to read when they finish this one.

    This query gets the latest 3 posts on the site, but adds a filter to
    exclude the post we're currently on from being included. --}}
    {{#get "posts" filter="id:-{{id}}" limit="4" as |more_posts|}}

        {{#if more_posts}}
            <aside class="read-more-wrap outer">
                <div class="read-more inner">
                    {{#foreach more_posts}}
                        {{> "post-card"}}


Also, according to the code the author should be on all cards, there is no if statement or anything. Also, the class="gh-card-author" is created, I can see it in the web inspector.

I guess there is nothing to patch, right?

Ah. You’re missing an include=authors from your {{#get}}

You have to include authors and tags explicitly if you need them. Otherwise the get helper doesn’t get them.

1 Like

Wouldn’t even think of it. You are awesome, thank you!

1 Like