views:

73

answers:

3

Hey,

Is there an easy way to redirect the user to the first post when he goes to the wordpress-installations main url.. Like, if he goes to domain.com, he will be redirected to domain.com/title-of-the-first-post..

A: 

Use your .htaccess file and do a redirect

Chris Holmes
+1  A: 

Chris Holmes answer if doing a redirect is a good one.

If htaccess is not an option, or you want to do it within WOrdPress. You can add simple logic to index.php using is_home_page(), and wp_redirect(). http://codex.wordpress.org/Function%5FReference/is%5Fhome http://codex.wordpress.org/Function%5FReference/wp%5Fredirect

If not really looking to program a solution, I imagine this is a good question for http://superuser.com/ Maybe, you are looking for http://codex.wordpress.org/Creating%5Fa%5FStatic%5FFront%5FPage

Lloyd Budd
A: 

After a few days of trying and failing, I was able to construct the following solution:

Add the following code to your header.php-file, located in wp-content/themes/nameOfTheme. Make sure there is no space or enter before the opening

<?php
if(is_home()) {
    $recentPosts = new WP_Query();
    $recentPosts->query('showposts=1');
    while ($recentPosts->have_posts()) : $recentPosts->the_post();
    wp_redirect(get_permalink(), 301);
    endwhile;
}
?>
Espenhh