Make WordPress Core

Opened 20 years ago

Closed 20 years ago

Last modified 13 months ago

#3876 closed enhancement (wontfix)

New template tag - get_latest_post

Reported by: drmike Owned by:
Priority: lowest Milestone:
Component: Template Version:
Severity: trivial Keywords:
Cc: Focuses:

Description

Greets:

Just a quick mention that I would like to see the template tag get_latest_post. This would generate a link directly to the latest post. I'm thinking it woul be used in such places as a static front page.

Thanks,
-drmike

Change History (2)

#1 @Otto42
20 years ago

  • Component Administration → Template
  • Priority low → lowest
  • Severity normal → trivial

This should probably not be in the core when it's so easy to simply stick into a plugin or a theme or a page template or what have you.

<?php 
function get_latest_post_permalink() {
$my_query = new WP_Query('showposts=1'); 
if ($my_query->have_posts()) {
$latest_post = $my_query->next_post();
return get_permalink($latest_post->ID);
} }
?>

#2 @rob1n
20 years ago

  • Milestone 2.3
  • Resolution → wontfix
  • Status new → closed

I don't see the need for this. Just do:

get_posts('orderby=post_date&count=1');
Note: See TracTickets for help on using tickets.