Easily show how many posts new members will have access to when they sign up.
· Dan Rowden
If you are offering member-only content in your Ghost site, you may want to show how many member-only posts there are, to prompt readers to sign up.
This is easy with a quick template tag.
{{#get "posts" filter="visibility:members,visibility:paid" limit="all"}}
<p>Become a member to support {{@site.title}} and get access to {{posts.length}} member-only posts.</p>
{{/get}}
This piece of code queries all posts with with Post access
marked as Members only
or Paid-members only
and shows the total number with {{posts.length}}
.
To query only paid posts, change the filter to filter="visibility:paid"
.
Make sure your sentence is wrapped by the {{#get}}...{{/get}}
tags.