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
craigs pva says
Finally a person that puts some actual work into a site. I do like what you have done with the site.
htc says
Sweet, that’s definitely what I was seeking for! You just saved me alot of work
Bee Brugnoli says
You are definitely a powerful writer. You absolutely know how to write to keep the audience engaged. I hope to read a lot more of your wonderful writing style in the future.