In my loop.hbs template I'm trying to get Ghost to pin posts that have the tag "Top" to the top. I'm using the {{#has}}
helper combined with a {{#foreach posts}}
.
See code below. The behaviour I'm getting though is that only the {{^has tag="Top"}}
(i.e. the second foreach
loop) is working.
Any clues as to what I might be doing wrong?
{{#foreach posts}}
{{#has tag="Top"}}
<article class="{{post_class}} top-post" style="background-color:lightgray">
<header class="post-header">
<h2 class="post-title"><a href="{{url}}">{{{title}}}</a></h2>
</header>
<section class="post-excerpt">
<p>{{excerpt words="26"}} <a class="read-more" href="{{url}}">»</a></p>
</section>
<footer class="post-meta">
{{#if author.image}}<img class="author-thumb" src="{{author.image}}" alt="{{author.name}}" nopin="nopin" />{{/if}}
{{author}}
{{tags prefix=" on "}}
<time class="post-date" datetime="{{date format='YYYY-MM-DD'}}">{{date format="DD MMMM YYYY"}}</time>
</footer>
</article>
{{/has}}
{{/foreach}}
{{! All the code above doesn't seem to be working. Only the below code outputs posts to the blog homepage }}
{{#foreach posts}}
{{^has tag="Top"}}
<article class="{{post_class}}">
<header class="post-header">
<h2 class="post-title"><a href="{{url}}">{{{title}}}</a></h2>
</header>
<section class="post-excerpt">
<p>{{excerpt words="26"}} <a class="read-more" href="{{url}}">»</a></p>
</section>
<footer class="post-meta">
{{#if author.image}}<img class="author-thumb" src="{{author.image}}" alt="{{author.name}}" nopin="nopin" />{{/if}}
{{author}}
{{tags prefix=" on "}}
<time class="post-date" datetime="{{date format='YYYY-MM-DD'}}">{{date format="DD MMMM YYYY"}}</time>
</footer>
</article>
{{/has}}
{{/foreach}}