Do you ever wanted to know how to create a blog with no home page? and which automatically redirect visitors to your latest blog post when trying to visit the homepage.
To apply this tip, paste the code below to your homepage file that is index.php . Please note that you’ll receive a PHP warning if you try to display anything before the wp_redirect() function on line 10.
<?php /* home.php (Blog Home Page): Redirect To First Post */ if (have_posts()) { while (have_posts()) { the_post(); wp_redirect(get_permalink()); } } ?>
The above code uses WordPress’s Redirect function to redirect your Homepage to your blog’s first page
Thanks to Ashton Sanders for the tip