Forums

Automatically redirect from index.php to single.php (2 posts)

  1. wp-photo
    Member
    Posted 1 year ago #

    Hello WordPress Community!

    This is my first post as it is the first time I could not find a solution on here. My question has already been raised by ChristopherMeeks, Errrwin (x2) & spiritbased, marc0047 but there has been no solution.

    I have been trying to get my index.php to redirect directly to the permalink single page of the latest post. This avoids pagination.

    Is there a way to use the loop to query the last permalink and then redirect automatically to it within index.php?

    I would really appreciate any help on this!

    Thank you in advance,

    Carolina

  2. wp-photo
    Member
    Posted 1 year ago #

    Ok, I have found a solution thanks to marc0047.

    By replacing index.php with only:

    <?php
    query_posts($query_string.'&posts_per_page=1');
    the_post();
    wp_redirect(get_permalink(), '302');
    return;
    ?>

    I was able to achieve what I wanted to do.

    Carolina

Topic Closed

This topic has been closed to new replies.

About this Topic