Link to the latest post in tag 'x'

HI there,

Is there a simple way of coding a URL to link to the latest post in a given ‘tag’.

If I create a weekly post called ‘weeknote’ - can I code a URL that will find the latest post on that category/tag?

Thanks… Matt.

Hey Matt

I like this idea of a permalink for the week note, with new content. Right off the top of my head I had two ideas for you, others might have better ones :stuck_out_tongue:

No code version

  1. make a post at https://www.mattrutherford.co.uk/weeknote
  2. end of week, change the slug on the post
  3. make a new post with the slug weeknote
  4. profit!

Code version

  1. make a page at https://www.mattrutherford.co.uk/weeknote
  2. make a custom template in your theme
  3. in the template use a get helper that retrieves just 1 post, the latest, from the tag weeknote and outputs however much content you want
  4. apply the theme to the weeknote page

Various riffs on this version, you could mess with the tag archive instead etc.

I think both have some implications for your stats if you’re tracking them (you’re splitting views between the weeknote version and the real version), and I’m not sure how comments would work with the get helper version :thinking:

2 Likes

Another option- make a page called week note and redirect (JavaScript) to the actual most recent post.

2 Likes

Oh, or use a ghost redirect each week :)

Lots of fun things!

1 Like

Ick. I don’t love the redirects upload process enough for that. :rofl:

I was thinking that with JavaScript you’d hit the content api to find out the most recent post, so it’d be fire and forget, no weekly update. (And no theme edit.)

1 Like

no code: swapping posts
low code: redirects
code+++++ all the other ideas

I love that we have a range of solutions, I can’t wait to see what Matt does with them :slight_smile:

I love these ideas - I don’t know enough to code a javascript redirect - but I know someone that does - I’m going to try and find out about that.

1 Like