Support » Themes and Templates » previous_post_link

Viewing 7 replies - 1 through 7 (of 7 total)
  • Are you using <?php previous_post_link(); ?> within the same while loop as <?php the_ID(); ?>? Does this single post use a custom template that queries for only one result?

    Also these two pages contradict each other…

    Actually, being deprecated—which previous_post is—does not mean that it doesn’t work. It means that it is scheduled not to work in a future release. Usually, deprecated functions sit in the wp-includes/deprecated.php file for a couple of versions before they’re removed entirely, in order to give developers fair warning.

    yes, the <?php previous_post_link(); ?> is right next to <?php the_ID(); ?> as in there is a line <?php the_ID(); ?>-<?php previous_post_link(); ?>.

    It’s a custom page (really outside the template)
    The loop is started with

    <?php $my_query = new WP_Query('category_name=main-posts&showposts=1');
    	while ($my_query->have_posts()) : $my_query->the_post(); ?>

    It could have something to do with the fact that you’re instantiating the WP_Class into a custom variable, $my_query, instead of $wp_query.

    Try using this instead:

    <?php query_posts('category_name=main-posts&showposts=1');
    	while (have_posts()) : the_post(); ?>

    still no luck with the previous link

    I’m thinking I might have to end up doing some hack involving getting 2 posts. Like…

    while (have_posts()) : the_post();
    …if count = 0 then
    ……output all the post stuff, then count++
    ……output link to post (labelled ‘previous post’)

    Right the main problem seems to be that I was doing previous_post_link when it should be previous_posts_link. Doh, don’t know how that changed.
    Also I need next_posts_link() as wordpress is weird and this is the latest post only.

    Trouble is it’s linking to is the page it’s on (not index.php, later it will be included from index.php but I would rather it worked regardless of the current file name), and ‘/page/2’ I don’t know because my blog urls are like ‘/2008/05/post-title’. So clearly it’s not linking to the right place.

    Second trouble, I’d like link name to be the blog title but it just shows ‘Next Page ยป’. Putting more than one partameter in the next_posts_link() and the link disappears completly, putting one and it shows the text but doesn’t change %title or %link.

    i’m having the same problem. was this ever resolved?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘previous_post_link’ is closed to new replies.