1

Is it possible to place conditions upon {{#prev_post}}{{title}}{{/prev_post}}? re: https://themes.ghost.org/docs/prev_next_post

For example, I'd like to be able to go to the next or previous post with filter="tags:-archive"

If prev_post & next_post isn't the right path, what could produce an equivalent function?

Wronski
  • 1,506
  • 3
  • 18
  • 37

1 Answers1

1

i run into similar question as well, google around but no-hope . here is my workaround right now, hope that helps.

for next_post:

{{!-- next_post to replace --}}
{{#next_post}}
  {{> "post-card"}}
{{/next_post}}

{{#get "posts" 
    filter="tags:{{primary_tag.slug}}+id:>{{id}}" 
    limit="1" 
    order="id asc"}}
  {{#foreach posts}}
    {{> "post-card"}}
  {{/foreach}}
{{/get}}

for prevuius post

{{!-- prev_post to replace --}}
{{#prev_post}}
  {{> "post-card"}}
{{/prev_post}}


{{#get "posts" 
    filter="tags:{{primary_tag.slug}}+id:<{{id}}" 
    limit="1" 
    order="id desc"}}
  {{#foreach posts}}
    {{> "post-card"}}
  {{/foreach}}
{{/get}}
Louis Law
  • 11
  • 2
  • `filter="tags:{{primary_tag.slug}}+id:>{{id}}"` <-- I'm curious about this bit. I'm relatively new to ghost: `tags:{{primary_tag.slug}}` <-- only return posts with primary_tag? `+id` <-- not sure what this does `>{{id}}` <-- only return posts with an id greater than the id of the current post being viewed? – Wronski Oct 14 '17 at 22:20
  • `+` is simply a logical `and` operation, so basically you need something with a matching tag AND an id that is higher/lower than the current id. – biziclop Jan 17 '18 at 23:46