Last active
August 29, 2015 14:05
-
-
Save dallasread/183bbd0c9552cf3e82bf to your computer and use it in GitHub Desktop.
A Wordpress template that redirects to your latest post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Latest Post Redirect | |
This page template will redirect to your latest post. | |
Simply create a new page and set the template as "Latest Post Redirect". | |
For specific categories, see http://codex.wordpress.org/Function_Reference/wp_get_recent_posts. | |
*/ | |
$recent_posts = wp_get_recent_posts( array( | |
'numberposts' => 1, | |
'orderby' => 'post_date', | |
'order' => 'DESC', | |
'post_type' => 'post', | |
'post_status' => 'publish' | |
) ); | |
wp_redirect( get_permalink($recent_posts[0]["ID"]), 302 ); | |
exit; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment