• Resolved samcrawshaw

    (@samcrawshaw)


    Hello,

    I was wondering if anyone could help me regarding pagination with wordpress?

    I have successfully used both wp_paginate and wp_pagenavi in my archives.php file but I’m struggling to use it in my page.php file.

    My page.php loops through pages>categories to display relvant posts but is not brining up the pagination.

    The code I have is:

    ...
    <?php if (have_posts()) while (have_posts()) : the_post(); ?>
    <?php if (is_page('6')){//home
    the_content();
    }else{?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); } ?>
    </div><!--end content_container_left_header-->
    
    <?php if (is_page('10') || is_child('10')){ //products ?>
    <div class="post_box">
    
    <!--22 product one-->
    <?php if (is_page('22')){
    $recent = new WP_Query();
    $recent->query('cat=7'); //22 product one posts are categorised as 7
    while($recent->have_posts()) : $recent->the_post();
    //custom fields
    $price = get_post_meta($post->ID, "Price", $single = true);
    $id = get_post_meta($post->ID, "ID", $single = true);
    $image = get_post_meta($post->ID, "pft_widescreen", $single = true);?>
    
    <div class="posts">
    <div class="content_container_left_post">
    <div class="content_container_left_post_header">
    <h3>Product ID: <span class="black"><?php echo $id; ?></span></h3>
    <h3><?php the_title(); ?></h3>
    </div><!--end content_container_left_post_header-->
    <div class="content_container_left_post_content">
    <p><?php the_excerpt(); ?></p>
    </div><!--end content_container_left_post_content-->
    <div class="content_container_left_post_footer">
    <h3>Price: <span class="black">&pound;<?php echo $price; ?></span></h3>
    <div class="more"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">More info ></a></div><!--end more-->
    </div><!--end content_container_left_post_footer-->
    </div>
    
    <div class="content_container_right_post">
    <div class="content_container_right_post_header">
    <img src="<?php echo $image; ?>" alt="<?php echo $id; ?>" />
    </div><!--end content_container_right_post_header-->
    </div><!--end content_container_right_post-->	
    
    </div><!--end posts-->
    <?php endwhile;}?>
    
    <p>wp_paginate</p>
    <?php wp_paginate(); ?>
    <p>wp_pagenavi</p>
    <?php wp_pagenavi(); ?>

    The if statements relate to another 7 or so. Is this something to do with way I am querying the pages or the custom fields?

    Many thanx in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter samcrawshaw

    (@samcrawshaw)

    Rookie mistake. Wasn’t using $paged.

    <?php if (is_page('22')){
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	query_posts("posts_per_page=4&cat=7&paged=$paged");
    	if ( have_posts() ) : while ( have_posts() ) : the_post();?>
    	<div class="posts">
    		content...
    		</div><!--end posts-->
    	<?php endwhile; else: endif;
    	if(function_exists('wp_paginate')){
    		wp_paginate();}
    	wp_reset_query();}?>
Viewing 1 replies (of 1 total)
  • The topic ‘Pagination using wp_paginate or wp_pagenavi in custom page’ is closed to new replies.