Hide author name for specific author site wide

Hello, I have a blog with multiple authors, the first author account created is sharing the same name as the website brand, it is used to post generic information that the other authors do not want to post.

We want ghost to automatically hide the author name block from any post made by this “brand” account. It is a bit redundant content wise and we like to set-up a hbs template to prevent this. (Using casper).

We want it remove this across the site, on post pages, partials on home and tag pages, etc. Any suggestions on how to do this? I looked through the documentation and I am not sure how to do this type of filter.

You can check who the author is with the {{#has}} helper :)

e.g.

{{^has author="John Doe"}}
  {{!-- NOT John Doe--}}
{{/has}}
1 Like

@vikaspotluri123

Thank you for pointing that out, I see its quite powerful, I am able to do it via this method, thanks!

1 Like

I found this post, but need more input…

Can you help point me to where I need to paste this code?

If you want to hide the author in the post, just edit the post.hbr in your theme. You will find a part like that:

{{#foreach authors}}
    <li class="author-list-item">
    (...)
    </li>
{{/foreach}}

You need to add the code like that:

{{#foreach authors}}
    {{^has author="John Doe"}}
        <li class="author-list-item">
        (...)
        </li>
    {{/has}}
{{/foreach}}

Same thing in index.hbs, post-card.hbs and wherever you want to hide the author.

Sorry… this isn’t working for me.

Someone else figured out how to do this with code injection. This worked for me:

1 Like

I have the same issue. Shodandad’s solution (the code injection) is no longer necessary because it’s just in the Ghost admin, but I don’t want to remove all authors - like the OP, I want to remove one specific author from the Author page (basically a staff account for announcements vs normal authors). I’m using the ^has author code suggested in this thread, with and without an else statement, and it isn’t working. Anyone have any suggestions?

Sounds like you’re using a theme that has a page that lists all authors. That’s a custom page within your theme, and it (or whatever partial it is calling) is what you need to edit. To find it in the theme, look for custom-whatever-the-template-name-is-for-that-page. (It will start with custom!) Then using the ^has helper should let you not show that author. It’s hard to give further advice without being able to see the site, knowing which theme it is, knowing what isn’t working (unwanted author appears vs no authors appear), or having access to the code.

It may be also possible to do this with code injection if you need to, but I’d have to see the site.

Hi Cathy! I am indeed using a theme that has a page that lists all authors, and I was indeed editing the custom template! I’m a bit hesitant to post the code publicly because it’s a paid theme. I’ve reached out to you!

@Cathy_Sarisky did an amazing job helping me! If you’re trying to find the solution too: “has” is for posts. “Match” is for the author page: Ghost Handlebars Theme Helpers: match

So just replace ‘has’ with ‘match’!