Single Post as Home Page

Add the following code to your functions.php in order to redirect your home.php template to the most recent single post

add_action( 'template_redirect', 'bavotasan_custom_template_redirect' );
function bavotasan_custom_template_redirect() {
   if ( is_home() ) {
      $latest_post_ID = get_posts( 'posts_per_page=1&fields=ids' );
      wp_redirect( get_permalink( $latest_post_ID[0] ) );
      exit();
  }
}

More information for similar setups in this article.

Leave a Reply

Posted in php
katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.