How to redirect your homepage to the first post

February 22nd, 2011 at 12:32am Jason 99 views

To apply this tip, paste the code below to your homepage file (Most of the time it is named 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());
    }
}
?>

via: http://www.wprecipes.com/how-to-redirect-your-homepage-to-the-first-post

Entry Filed under: WordPress Tagged with:

Share This Post Share This Post SubscribePrint This Post Print This PostSave As PDF Save As PDF

Related Posts Hot Posts Hot Comments Hot Tags

      Leave a Comment

      Required

      Required, hidden

      Some HTML allowed:
      <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

      Trackback this post  |  Subscribe to the comments via RSS Feed


      Calendar

      February 2011
      MTWTFSS
      « Jan Mar »
       123456
      78910111213
      14151617181920
      21222324252627
      28 

      Sponsors

      Most Recent Posts