Viewing 5 replies - 1 through 5 (of 5 total)
  • Your page template must be using a custom query. It’s this query that needs amending.

    Thread Starter ailinalei

    (@ailinalei)

    I don’t understand. Sorry. So you’re saying page.php needs to be changed/updated? How? Do you think I should add the following codes to page.php? If so, where? I got these codes from loop.php. Please let me know if i’m on the right track or if there is something else I need to do. Thanks! =)

    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
    	<div id="nav-above" class="navigation">
    		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    	</div><!-- #nav-above -->
    <?php endif; ?>
    
    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if (  $wp_query->max_num_pages > 1 ) : ?>
    				<div id="nav-below" class="navigation">
    					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
    					<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    				</div><!-- #nav-below -->
    <?php endif; ?>

    This is how my page.php looks like:

    <?php
    /**
     * The template for displaying all pages.
     *
     * This is the template that displays all pages by default.
     * Please note that this is the wordpress construct of pages
     * and that other 'pages' on your wordpress site will use a
     * different template.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    ?>
    
    <?php get_header(); ?>
    
    		<div id="container">
    			<div id="content" role="main">
    
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<?php if ( is_front_page() ) { ?>
    						<h2 class="entry-title"><?php the_title(); ?></h2>
    					<?php } else { ?>
    						<h1 class="entry-title"><?php the_title(); ?></h1>
    					<?php } ?>				
    
    					<div class="entry-content">
    						<?php the_content(); ?>
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
    					</div><!-- .entry-content -->
    				</div><!-- #post-<?php the_ID(); ?> -->
    
    				<?php comments_template( '', true ); ?>
    
    <?php endwhile; ?>
    
    			</div><!-- #content -->
    		</div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Thread Starter ailinalei

    (@ailinalei)

    help please…thank you.

    Thread Starter ailinalei

    (@ailinalei)

    i’ve been working to fix for days now. it’s in the query but just don’t have a clue what to fix. please help….

    [code moderated]

    unfortunately, you are looking into the wrong file (a wordpress core file).

    you page (id=4) is using a page template that is using custom query to get the post.

    first step: to identify the page template file which is attributed to your page;
    go and edit the page with the id=4 and look at the right under ‘attributes’ under ‘template’ –
    then go through all the php files in your theme folder (as the file name is unfortunately independant of the template name inside) and look into these files at the top to see if you an find this template name;
    (in a page template file, this should look like:

    <?php
    /*
    Template Name: Snarfer
    */
    ?>

    with the template name instead of ‘Snarfer’ )
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
    (actually, in fact, take the time to study the whole document).

    second step: if you have this page template file, edit it and look for a line with ‘query_posts()’ – this is your custom query that @esmi was mentioning.

    this might be missing the ‘paged’ parameter:
    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Function_Reference/query_posts#Pagination_Parameters
    which might need to be added with some extra code before:
    (similar as described here; http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/ )

    if you are struggeling with this second step, you could also paste the content of this page template file into a http://wordpress.pastebin.com/ and post the link to it here. someone might then have a look at it and might be able to give some advice.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘next and previous posts links not working’ is closed to new replies.