Forum

Thread tagged as: Question

Linking to the most recent post made in categories

In the main menu of my site I want to link to the most recent post made in categories (so any category in any set).

Can I do this and what would the code look like?

Andrew Areoff

Andrew Areoff 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you talking about the Blog app?

No categories.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok - what constitutes a post in your circumstance?

An entry or page that is within the categories section/app.

Let's call the post a 'portfolio item' as per your categories video.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Content doesn't live within the Categories app. You categorise content, and then you can filter it by the category.

To get the most recent, you'll need to have a sense of the creation date, so make sure you have a date field on the content.

Sort by the date field, descending, to get the most recent at the top.

Filter by the category.

Limit to one item.

That's the most recent item in that category.

That sounds like a perfect solution!

I've just added in the date field.

Thanks for your help there.

Drew McLellan

Drew McLellan 2638 points
Perch Support

No problem.