WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Next and Previous page showing wrong pages (7 posts)

  1. praveen68
    Member
    Posted 1 year ago #

    Hi! I have installed plugin Next Page, Not Next Post.
    It works great. I have 10 page templates ranging from order 1-10. Each page have 1 post and previous and next link. I have given codes as mentioned in http://binarym.com/2009/next-page-not-next-post/ I have given sequential order numbers and one custom fields to all pages.
    My problem is all 10 pages show the same previous and next page. What am I missing. I am not very well versed with php coding. Is there any other way to give navigation to page templates belonging to a custom field. Please guide.

  2. Archie22is
    Member
    Posted 1 year ago #

    Sometimes plugins are not the best thing in the world.... sometimes. #No offence to anyone.

    I would suggest using the following php code in your website:

    <nav id="nav-single" class="group">
    	<ul>
    		<!-- for previous -->
    		<?php if (get_adjacent_post(false, '', false)): // if there are older posts ?>
    		<li class="nav-previous"><?php next_post_link( '%link', __( '<span class="icon"> </span>', 'yourtheme' ) ); ?></li>
    		<?php endif; ?> 
    
    		<!-- for current -->
    		<li class="nav-bloghome"><a href="<?php bloginfo('url'); ?>/blog"><span class="icon"></span>All Posts</a></li>
    
    		<!-- for next -->
    		<?php if (get_adjacent_post(false, '', true)): // if there are newer posts ?>
    		<li class="nav-next"><?php previous_post_link( '%link', __( '<span class="icon"></span> ', 'yourtheme' ) ); ?></li>
    		<?php endif; ?>
    	</ul>
    </nav><!-- #nav-single -->
  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    I have 10 page templates ranging from order 1-10. Each page have 1 post and previous and next link.

    are these page templates using a custom query? is the query properly reset at the end of the loop?

    can you post the full code of the templates?

    given sequential order numbers and one custom fields to all pages

    how are custom fields suppose to integrate with the plugin?

  4. praveen68
    Member
    Posted 1 year ago #

    This is the code I put in all page templates. I use plugin "http://binarym.com/2009/next-page-not-next-post/ . I am finding difficulty with wordpress logic and need expert guidance. :-)

    <?php
    // Exit if accessed directly
    if ( !defined('ABSPATH')) exit;
    
    /**
     * The name Template
     *
       Template Name:  Name Template
     *
     * @file           name-template.php
     */
    ?>
    <?php get_header(); ?>
    	<div class="grid-12">
    	  <div class="grid-8 alpha">
    	    <?php query_posts('p=515'); ?>
    		<?php while (have_posts()) : the_post(); ?>
    		  <h3><?php the_title(); ?></h3>
    		  <?php the_content(); ?>
    		  <?php endwhile;?>
    	  </div>
    <?php $nextPage = next_page_not_post('Next Page', 'true', 'order_by=custom&meta_key=daily-menu&loop=1&sort_order=asec');
     $prevPage = previous_page_not_post('Previous Page', 'true', 'order_by=custom&meta_key=daily-menu&loop=1&sort_order=asec');
    
     if (!empty($nextPage) || !empty($prevPage)) {
     echo '
    <ul id="nextPrevPages">';
    
     if (!empty($nextPage)) echo '
     <li class="next">'.$nextPage.'</li>
    ';
     if (!empty($prevPage)) echo '
     <li class="previous">'.$prevPage.'</li>
    ';
    
     echo '</ul>
    ';
     }
    ?>
    </div> <!-- END grid-12 -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thank you.

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    by using the 'query_post()' code you are messing with the orignal page information;

    try and add <?php wp_reset_query(); ?> after the line with 'endwhile'.

  6. praveen68
    Member
    Posted 1 year ago #

    Wow! alchymyth. You made my day. Now I am getting different pages in next and previous. It does not show in the sequence I have give using page tree view plugin. What am I missing. Thank you.

  7. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    possibly continue with your original topic in the plugin's support section, and add the latest information there;

    [to be continued at http://wordpress.org/support/topic/next-and-previous-page?replies=1 ]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.