WordPress.org

Forums

redirect index.php to latest post (single.php format) (4 posts)

  1. moatley
    Member
    Posted 6 years ago #

    Hi,

    I am new to this version of wordpress... I used to turn themes off in older versions and had quite a bit of flexibility in redirecting pages... things are different now so, I feel like a baby.

    Here is what I want: When a user comes to the homepage of my blog I want them to see the newest post (only one) AND be able to navigate to a previous post. Also, they need to be able to comment RIGHT THERE on the latest post if they so desire.

    I literally want the index page to look and function exactly like the single.php page.

    I was thinking a simple redirect with the newest post id attached would do it... but I just don't know how to do this.

    PLEASE PLEASE PLEASE help, or direct me to the answer. (I have already exhausted the forums looking for this... no one seems to have a clear method for doing this... always with some of the functionality I'm looking for, but not ALL of it).

    Let me know asap. Thanks! I'll also give anyone who delivers a clear answer credits in my code. Thanks!

    M

  2. MichaelH
    Member
    Posted 6 years ago #

    Just set the Blog pages show at most via Administration > Settings > Reading to one (1).

  3. xewax
    Member
    Posted 6 years ago #

    If you want to have just one post when someone visits your blog I would recommend this
    [spam link moderated]
    But Michael's solution is better decision.

  4. ness
    Member
    Posted 5 years ago #

    I am not an expert, so this might be a tweaked script that needs more tweaking, but I managed to redirect my front page to the latest post with this:

    <?php
    			//list post title for one post is specified category
    			$cat = 1; //category ID
    			   $args=array(
    			   'category__in' => array($cat),
    			   'showposts'=>1,
    			   'caller_get_posts'=>1
    			   );
    			$my_query = new WP_Query($args);
    			if( $my_query->have_posts() ) {
    			while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    			<?php
    			endwhile;
    			}
    			wp_reset_query();  // Restore global post data stomped by the_post().
    			?>
    			<script>
    			location = "<?php the_permalink() ?>";
    			</script>

Topic Closed

This topic has been closed to new replies.

About this Topic