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
  • WhatsApp
  • Email

Related

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

Comments

  1. craigs pva says

    September 24, 2010 at 11:22 pm

    Finally a person that puts some actual work into a site. I do like what you have done with the site.

    Reply
  2. htc says

    October 2, 2010 at 5:29 pm

    Sweet, that’s definitely what I was seeking for! You just saved me alot of work

    Reply
  3. Bee Brugnoli says

    October 3, 2010 at 7:56 am

    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.

    Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post navigation

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

Currently Trending

  • How to download Specific parts of YouTube videos
  • How to Change the Welcome/Login Screen in Windows XP ?
  • Windows Vista CD key
  • Embed Text Resizing Widget To Increase or Decrease The Font Size
  • Free Online Angry Birds game
  • Different way’s to shutdown your pc
  • Check if your Antivirus Is Working Properly
  • Free Online Virus and Malware Scan
  • HTTP2 Server Push for W3 Total Cache Minify plugin
  • 110 Amazing Magic Tricks with Everyday Objects - eBook

Get Latest post in your Inbox

Random Posts

Windows 8 Shortcut Keys

December 23, 2012 By Ritesh Sanap Leave a Comment

Make Money Using Twitter !

August 11, 2009 By Ritesh Sanap 6 Comments

How to Automatically Empty Trash

May 10, 2012 By Ritesh Sanap Leave a Comment

Chit Chat for Facebook

December 3, 2010 By Ritesh Sanap Leave a Comment

Special Google Services

February 29, 2008 By Ritesh Sanap Leave a Comment

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

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