Search code examples
node.jshandlebars.jsghost-blog

How to get all posts that are paid and public with ghost


I am trying to create custom pages example.com/free that get all free post and example.com/pro that get all paid posts but I cannot solve it making this:

{{!< default}}

{{#post}}

<div class='c-archive'>
  <h1 class='c-archive__title'>{{ title }}</h1>
</div>

<div class='o-grid'>
  {{#get 'posts' filter="visibility:paid"}}
    {{#foreach posts}}
      {{> post-card }}
    {{/foreach}}
  {{/get}}
</div>

{{/post}}

Solution

  • this is the solution to get all paid post

    {{!< default}}
    
    {{#post}}
    
      <div class='c-archive'>
        <h1 class='c-archive__title'>Pro Lessons</h1>
      </div>
    
      <div class='o-grid'>
      {{#get 'posts'}}
        {{#foreach posts visibility='all'}}
          {{#has visibility="paid"}}
            {{> post-card-custom }}
          {{/has}}
        {{/foreach}}
      {{/get}}
    
      </div>
    
    {{/post}}