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.

    Thread Starter nomoregrapes

    (@nomoregrapes)

    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(); ?>
    Thread Starter nomoregrapes

    (@nomoregrapes)

    still no luck with the previous link

    Thread Starter nomoregrapes

    (@nomoregrapes)

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

    query_posts(‘category_name=main-posts&showposts=2’);
    while (have_posts()) : the_post();
    …if count = 0 then
    ……output all the post stuff, then count++
    …else
    ……output link to post (labelled ‘previous post’)
    …endif
    endwhile

    Thread Starter nomoregrapes

    (@nomoregrapes)

    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 http://www.example.com/example.php/page/2
    example.com/example.php 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.