• Resolved nipponese

    (@nipponese)


    Hi,

    I am trying to create a link to the second to last post.

    I tried:
    <?php previous_post_link( '%link', '<span class="meta-nav">&laquo;</span> %title', in_same_cat, TRUE ) ?>

    But I guess because I am using a <?php the_post() ?> instead of the loop on a category-x.php page, it doesn’t work.

    Any help would be appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You’ve got an error in that you can’t have TRUE as a value in excluded categories. That’s either got to be a number (ie. the category you’re excluding) or blank: as you’ve opted for in_same_cat it’s redundant anyway – Codex.

    How do you mean a link to the second to last (penultimate) post – is it a link that is always going to take you to the penultimate post no matter what the post is, or is it that you just want a link to the post (ie. ?p=83783)?

    Thread Starter nipponese

    (@nipponese)

    Whoa, my vocab for the day.

    penultimate post no matter what the post is

    Yeah, this is what I’m trying to achieve.

    Okay, good question… I’ll have a think – there might be a plugin that gets the first post, which you’d want to change to the second post.

    Does it need to be the second post from the category a user is browsing or just the second post ever?

    Thread Starter nipponese

    (@nipponese)

    Second post in the category currently being viewed.

    Maybe you’re curious, this is my situation: I am making a site for an artist who wants to split his site up into two sections: Art and Writing. So I just made one category Writing, and the other Art.

    So the nav is just a list of categories. When you click one of the category links, he wants it to jump directly into the last post, as I mentioned. Additionally, he wants a button on that same page that will jump to the ‘next’ posting, which is actually the penultimate post.

    It’s a veeeery basic and custom gallery system (which is what most of these artists seem to want).

    I should ask, as an alternative, is there a way to just make clicking the category link jump to the last posts’ permalink?

    Then can’t you just use next_post_link() to get to the one before it (as you’re going backwards)?

    To go straight to the first one you could write the db query yourself – instead of using have_posts() you could query the database and sort the timestamp so that you get the first one at the top? There must be a function where you can call this somewhere…

    Thread Starter nipponese

    (@nipponese)

    It definitely would be cool to find a function for this… Anyone know of anything?

    Thread Starter nipponese

    (@nipponese)

    If anyone has the same problem, this plugin does what I need:
    https://www.dagondesign.com/articles/latest-post-from-each-category-plugin-for-wordpress/

    …after a little modification.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Link to second to last post?’ is closed to new replies.