Best 2 Know

The Ultimate Blogging Resource

  • Advertising
  • WebHosting
  • Contact Us
  • Blogger
    • Blogger Templates
    • Blogger Tutorials
  • Browser
    • Firefox
    • Google Chrome
  • Google
  • Internet
    • Facebook
    • Twitter
  • Thesis
  • Windows
  • WordPress
    • WordPress Themes
    • WordPress Plugins
  • More
    • Linux
    • Review
    • Solutions
    • Announcements

How to redirect your homepage to the first post

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

Subscribe via Email

Share this:

  • Twitter
  • Facebook
  • Pocket
  • Print
  • Email

Related

March 22, 2011 Ritesh Sanap WordPress home, post, redirection, Tricks, wordpress hacks, WordPress Tips

Post navigation

Previous Previous post: How to turn off Post Revisions
Next Next post: How to disable Rotator in thesis

Currently Trending

  • Windows Vista CD key
  • How to download Specific parts of YouTube videos
  • ZooZooo - Vodafone Logos
  • How to Increase Dropbox upload speed
  • How to Change the Welcome/Login Screen in Windows XP ?
  • How To Change Windows XP Shutdown Dialog Box
  • HORIZONTAL AND VERTICAL SPACING
  • List Of All 255 Keyboard All Alt Key Codes
  • Hide or Show Label Count In Blogger
  • Free Online Angry Birds game

Random Posts

How to Check the Time of the Executed Command

February 26, 2011 By Ritesh Sanap 2 Comments

Insert your Name in Taskbar

February 29, 2008 By Ritesh Sanap Leave a Comment

From Netbook to Jetbook- Make your notebook super fast

March 14, 2009 By Ritesh Sanap 5 Comments

GTalk Tips and Tricks / Shortcuts

August 25, 2009 By Ritesh Sanap 2 Comments

Satoshi Blogger Template

July 21, 2010 By Ritesh Sanap 5 Comments

WordPress

HTTP2 Server Push for W3 Total Cache Minify plugin

August 17, 2016 By Ritesh Sanap 5 Comments

How to Disable Emojis in WordPress

January 6, 2016 By Ritesh Sanap Leave a Comment

JetPack Related posts and Sharing not working with NGINX

November 10, 2015 By Ritesh Sanap Leave a Comment

Simply Pure – WordPress Theme

November 2, 2014 By Ritesh Sanap 2 Comments

Advanced What should we Write about next? – WordPress Plugin

July 28, 2014 By Ritesh Sanap Leave a Comment

How to Disable Self Pingback or TrackBack

January 16, 2014 By Ritesh Sanap Leave a Comment

BlueStrap – WordPress Theme

January 1, 2014 By Ritesh Sanap 15 Comments

How to Create Multiple Excerpts in WordPress

December 24, 2013 By Ritesh Sanap Leave a Comment

How to Disable Auto Update in WordPress

November 21, 2013 By Ritesh Sanap Leave a Comment

How to Delete Feedbacks from JetPack Contact Form

November 19, 2013 By Ritesh Sanap 9 Comments

Recent Posts

  • HTTP2 Server Push for W3 Total Cache Minify plugin
  • How to show hidden files and folders in Mac OS X
  • How to Disable Emojis in WordPress
  • Canva – Online Photo Editor
  • JetPack Related posts and Sharing not working with NGINX

Archives

Recommends

  • DigitalOcean – Cloud Hosting
  • Dropbox – Cloud Storage
  • Elegant Themes – WordPress Themes
  • LastPass – Password Manager
  • Like us on Facebook
  • Follow on Twitter
  • +1 on Google
  • Subscribe via Email
  • RSS Feed

© 2021 Best 2 Know · All Rights Reserved · We ♥ DigitalOcean

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.