WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Next and previous links don't work (6 posts)

  1. objecpers
    Member
    Posted 3 years ago #

    I created a page of posts from one category of my blog. In the settings, I have it set to show only the most recent 7 posts. I put `<div class="navigation"><p><?php posts_nav_link('∞','«« Go Forward
    In Time','Go Back in Time »»'); ?></p></div>` to put in links to go to the next and previous pages. However, when I click either link at the bottom of the page, it takes me to the most recent 7 posts. How do I make it so that I can navigate to the previous posts. The page in question is located at http://modesofbeing.com/photo-diary/page/2/ .

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    what is the code of your custom query on that page template?

    (if the code snippet is longer than 10 ines, please paste it into a http://pastebin.com/ and post the link to it here)

    try to integrate the 'paged' parameter:
    http://codex.wordpress.org/Function_Reference/WP_Query#Pagination_Parameters

  3. objecpers
    Member
    Posted 3 years ago #

    My query is

    <?php query_posts('cat=299'.get_the_title().'&post_status=publish,future');?>
    
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    	<p><?php the_content(); ?>
    	<?php endwhile; else: endif; ?>
  4. caugb
    Member
    Posted 3 years ago #

    get_the_title() gets the title of the current post... placed here it was only breaking your query.

    query_posts('cat=299&post_status=publish,future');

  5. alchymyth
    Forum Moderator
    Posted 3 years ago #

    also, maybe try to integrate the 'paged' parameter:

    <?php query_posts('cat=299&post_status=publish,future&paged=' . get_query_var('paged'));?>

  6. objecpers
    Member
    Posted 3 years ago #

    Thanks! It works now.

Topic Closed

This topic has been closed to new replies.

About this Topic