# Hide "member only" posts on index page if not connected

**URL:** <https://forum.ghost.org/t/hide-member-only-posts-on-index-page-if-not-connected/19547>\
**Category:** Memberships & subscriptions\
**Created:** [January 18, 2021, 3:32am UTC](https://forum.ghost.org/t/hide-member-only-posts-on-index-page-if-not-connected/19547 "2021-01-18T03:32:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iero](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@iero](https://forum.ghost.org/u/iero)\
**Post date:** [January 18, 2021, 3:32am UTC](https://forum.ghost.org/t/hide-member-only-posts-on-index-page-if-not-connected/19547/1 "2021-01-18T03:32:37Z")

</div>

Hello

Is it possible I would like to hide “member” posts from the index page if the user is not connected?  
Or at least, if it’s not possible, add a “lock” icon on those posts

Thanks

---

<div class="post-metadata">

**Author:** ![pieter](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/pieter/32/11499_2.png) [@pieter](https://forum.ghost.org/u/pieter)\
**Post date:** [January 18, 2021, 1:52pm UTC](https://forum.ghost.org/t/hide-member-only-posts-on-index-page-if-not-connected/19547/2 "2021-01-18T13:52:10Z")

</div>

It is possible to make this configuration in your theme.

First of all, make sure that all posts are displayed, by looking for the `foreach` statement in the `index.hbs`. It is explained in the “visibility in posts” section on the membership documentation page:

> Posts that are set to `members-only` or `paid-members only` won’t appear in post archives unless the `visibility="all"` flag is included with the `#foreach` helper:

> **[Ghost Theme Development: Building custom membership flows](https://ghost.org/docs/themes/members/#visibility-in-posts)**
>
> Find out how to build a custom theme for a Ghost Members site, with signup and signin, paid subscriptions, member accounts and more 👉

Next, you can use the `visibility` helper to create a custom CSS class for the non-public posts and create a style that introduces the lock icon. You can find this use case in the “visibility” section on the membership documentation page

```auto
<svg>
    <use xlink:href="#icon-{{visibility}}"></use>
</svg>

```

> **[Ghost Theme Development: Building custom membership flows](https://ghost.org/docs/themes/members/#visibility)**
>
> Find out how to build a custom theme for a Ghost Members site, with signup and signin, paid subscriptions, member accounts and more 👉

---

<div class="post-metadata">

**Author:** ![iero](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@iero](https://forum.ghost.org/u/iero)\
**Post date:** [January 18, 2021, 6:23pm UTC](https://forum.ghost.org/t/hide-member-only-posts-on-index-page-if-not-connected/19547/4 "2021-01-18T18:23:54Z")

</div>

thanks @pieter! I just tried to play with parameters.

But if I remove/change the visibility tag, members posts will disappear for everybody, even the connected members.

What I would like, if possible is to put in the index.hbs something as:  
if user is a member  
see post

Is this possible?

---

<div class="post-metadata">

**Author:** ![iero](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@iero](https://forum.ghost.org/u/iero)\
**Post date:** [January 18, 2021, 6:39pm UTC](https://forum.ghost.org/t/hide-member-only-posts-on-index-page-if-not-connected/19547/5 "2021-01-18T18:39:01Z")

</div>

Thanks for your help @pieter!

I updated _index.hbs_ file with in order to display all articles for connected members and public articles for not connected members:

```
   <div class="post-feed">
        {{#if @member}}
            {{#foreach posts visibility="all"}}
                {{> "post-card"}}
            {{/foreach}}

        {{else}}
            {{#foreach posts }}
                {{> "post-card"}}
            {{/foreach}}
        {{/if}}
    </div>
```
