Forums

Direct link to first post in category (4 posts)

  1. niknak
    Member
    Posted 3 years ago #

    Is there a way to set it so that when a user clicks on a category link it takes the user to the first post in the category (i.e. instead of going to http://www.website.com/category/ it goes directly to http://www.website.com/category/LatestPost)?

    I have it set so only one post appears at most per page, which means going to the main category page is pointless. Although it seems trivial, this means that my next_post_link & previous_post_link don't appear until the user clicks on the post's title, finally getting to the single post.

    Thanks for any suggestions...

  2. c-bass
    Member
    Posted 2 years ago #

    did you find it out? i am also interested in this

  3. Ralev
    Member
    Posted 2 years ago #

    I'm very interested in this one, too.

  4. formica
    Member
    Posted 2 years ago #

    Untested but give this a try...

    <?php $postslist = get_posts('category=5&numberposts=1&order=DESC&orderby=post_date');
         foreach ($postslist as $post) :
         setup_postdata($post); ?>
       <li><a href="<?php the_permalink() ?>">Work</a></li>
    <?php endforeach; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic