WordPress.org

Ready to get started?Download WordPress

Forums

How to get permalink to the 2nd post on Index.php (3 posts)

  1. knightkato
    Member
    Posted 5 years ago #

    Hey,

    I've been trying for a while to figure out how to do this,

    On the first page (index.php) i want to have the first post, but when I click the permalink i want it to take me to the 2nd post on single.php. So I need a way to re-route the permalink and offset it by 1.

    This won't work with query_posts() since it will change what will be displayed on the first page..

    Any ideas on how to do this?

  2. tslice
    Member
    Posted 5 years ago #

    Place within wp loop:

    <?php $post2 = get_posts('numberposts=1&offset=1' ); ?>
    <a href="<?php echo get_permalink( $post2[ 0 ]->ID ); ?>"><?php echo $post2[ 0 ]->post_title; ?></a>
  3. knightkato
    Member
    Posted 5 years ago #

    Thanks! Exactly what I needed. You the man!

Topic Closed

This topic has been closed to new replies.

About this Topic