Your sites Log in Sign up Menu

Sticky posts in Magazine template

I'm trying to figure out a way to make a post "sticky" or have some sort of Featured post that stays at the top of my Home page, and I'm struggling. I had found a question asking this about the Blog template and it was working fine when that was the only post on my site. Now that I've added more posts, though, the Sticky post is just having a plain hyperlink of its title displayed at the top of the page rather than the full width post I was seeing before.

Is there any way to do this and have it work consistently on the Magazine template?


a year ago, 3 replies   metadata   Improve this question

You will need to adjust your template code such that you render the full post, typically using the {{{html}}} tag, rather than just the {{title}}, for example:


<p>Sticky entries:</p>

{{#allEntries}}
{{#metadata.sticky}}

{{{html}}}

{{/metadata.sticky}}
{{/allEntries}}
Answered a year ago · Improve this answer

This is what I was doing but unfortunately it broke the second I had more than one post on the site.

Answered a year ago · Improve this answer

Wanted to follow up on this because I got it working. I have no explanation for why this issue occurred, but the fix was simple.

When using the code provided above it worked fine until I added more posts. Once more posts appeared it either displayed just the post title as a hyperlink with no styling or displayed the post as required, but with the post title repeated beneath it as a hyperlink with no styling. In the first instance this occured when the other posts had no reference to "Sticky" in their header. When they instead had "Sticky: No" in the header, the second result occured.

As an experiment I stopped using the word "Sticky" in the header. Replacing it with a different word (in my case I'm using "Promoted") and changing the code to say:

{{#allEntries}} {{#metadata.promoted}}

{{{html}}}

{{/metadata.promoted}} {{/allEntries}}

For some reason this now works perfectly. I can only assume the word "Sticky" is interfering with something else in the CSS in some way. Whether that's something in the Magazine template by default or something I've added while inexpertly changing things, I have no idea.

Answered a year ago · Improve this answer