How to determine a posts visibility

I’m creating a custom theme at the moment.

I need to determine a post’s visibility (public, members, paid) but am struggling. Currently I have this conditional to test if a post is currently not visible to the viewer:

{{#unless access}}
    {{#has visibility="paid"}}
        <p>This is a paid article</p>
    {{/has}}
        {{#has visibility="member"}}
    <p>This is a member's article</p>			
    {{/has}}
    <p>This will show if the viewer can't see the contents</p>		
{{/unless}}

The theme is correctly showing the <p>This will show if the viewer can't see the contents</p> line but the {{#has visibility="paid"}} bit isn’t working.

Am I misunderstanding the use case here?

Hi @garrypettet,

There is one mistake in the code, the visibility is members not member.

{{#has visibility="members"}}
  <p>This is a member's article</p>			
{{/has}}

I did a quick check in my local Ghost instance and this works for paid and members posts (texts show up as expected).

3 Likes

Great spot. Thanks!

1 Like