WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
WP-PageNavi only displaying first page. (12 posts)

  1. juliangav
    Member
    Posted 1 year ago #

    I just installed the plugin and it only displays the first page. To keep a long story short I'll just paste the code:

    [code moderated - use the pastebin for any code over the forum limit of 10 lines]

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. bruno.fernandes
    Member
    Posted 1 year ago #

    As you are using a custom query you must pass it to the wp_pagenavi function. Something like:

    wp_pagenavi( array( 'type' => 'multipart' , 'query' => $posts) );

    Hope that helps.

  3. bruno.fernandes
    Member
    Posted 1 year ago #

    And move the function to be before wp_reset_query() function.

  4. juliangav
    Member
    Posted 1 year ago #

    Thanks for the quick response Bruno. Still not working though. I did as you said; the code looks like this now

    <?php
    
    	/*
    		Template Name: Grants
    	*/
    ?>
    <?php get_header(); ?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<h1><?php the_title(); ?> <span><?php echo get_post_meta($post->ID, 'board-title', true); ?></span></h1>
    		<?php get_sidebar(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<div id="content" class="entry">
    				<?php the_content(); ?>
    
    				<?php global $query_string; $posts = query_posts( array( 'cat' => 9, 'paged' => get_query_var('page') ) );?>
    				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    				<?php global $more; $more = 0; ?> <!-- enabling 'more' -->
    					<article>
    						<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    						<p class="meta">Published on: <?php the_time('F jS, Y') ?> | Courtesy of <a href="http://<?php echo get_post_meta($post->ID, 'author', true); ?>"><?php echo get_post_meta($post->ID, 'author', true); ?></a></p>
    						<?php the_content('Continue Reading &raquo;'); ?>
    					</article>
    				<?php endwhile; ?>
    				<?php endif; ?><?php wp_pagenavi( array( 'type' => 'multipart' , 'query' => $posts) ); ?>
    				<?php wp_reset_query(); ?>
    
    				<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    			</div>
    		</div>
    	<?php endwhile; endif; ?>
    <?php get_footer(); ?>
  5. juliangav
    Member
    Posted 1 year ago #

    Using pastebin now: http://pastebin.com/JQYcyTmd

  6. bruno.fernandes
    Member
    Posted 1 year ago #

    Try this:

    <?php
    
    	/*
    		Template Name: Grants
    	*/
    ?>
    <?php get_header(); ?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<h1><?php the_title(); ?> <span><?php echo get_post_meta($post->ID, 'board-title', true); ?></span></h1>
    		<?php get_sidebar(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<div id="content" class="entry">
    				<?php the_content(); ?>
    
    				<?php global $query_string; $posts = query_posts( array( 'cat' => 9, 'paged' => $paged ) );?>
    				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    				<?php global $more; $more = 0; ?> <!-- enabling 'more' -->
    					<article>
    						<h2><a>"><?php the_title(); ?></a></h2>
    						<p class="meta">Published on: <?php the_time('F jS, Y') ?> | Courtesy of <a>ID, 'author', true); ?>"><?php echo get_post_meta($post->ID, 'author', true); ?></a></p>
    						<?php the_content('Continue Reading »'); ?>
    					</article>
    				<?php endwhile; ?>
    				<?php endif; ?><?php wp_pagenavi( array( 'type' => 'multipart' , 'query' => $posts) ); ?>
    				<?php wp_reset_query(); ?>
    
    				<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    			</div>
    		</div>
    	<?php endwhile; endif; ?>
    <?php get_footer(); ?>
  7. juliangav
    Member
    Posted 1 year ago #

    Got it to work but with the regular <?php wp_pagenavi(); ?>

    Just a letter difference in the word 'paged'...lol wow. Thanks a bunch!

  8. bruno.fernandes
    Member
    Posted 1 year ago #

    Glad you made it!

  9. Dre4000
    Member
    Posted 1 year ago #

    Im having the same issue here is the code:

    function News(){
    if (is_page('Backyard Blog')) {
    ?>
    <div id= "Blog">
    
    <div id= "BBlog">
    <?php
    $custom_loop = new WP_Query('posts_per_page=-2&category_name=Uncategorized&orderby=date');
    if ( $custom_loop->have_posts() ) :
    while ( $custom_loop->have_posts() ) : $custom_loop->the_post();
    $post_image = thesis_post_image_info('thumb');
    echo '<div class="post type-post hentry post_box top">';
    echo $post_image['output'];
    echo '<div class="headline_area"><h5 class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h5>';
    echo '<p class="headline_meta"><abbr title="" class="published">' . get_the_date() . '</abbr></p></div>';
    echo '<div class="format_text entry-content"><p>' . get_the_excerpt() . '</p></div>';
    echo '<a href="' . get_permalink() . '">' . '<span class="slider-more-button published">Read More »</span></a>';
    echo '</div>';
    endwhile;
    if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    wp_reset_query();
    endif;
    ?></div> 
    
    </div><?php  
    
            }
        }
    add_action('thesis_hook_after_headline','News');
  10. Dre4000
    Member
    Posted 1 year ago #

    I found help on this page by second example on this page:

    function News(){
    if (is_page('Backyard Blog')) {
    ?>
    <div id= "Blog">
    
    <div id= "BBlog">
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $custom_loop = new WP_Query(array(
      'paged' => $paged,
      'post_type' => 'post',
      'cat' => 1,
      'posts_per_page' => 2,
      'orderby_order'    => 'date'
    ));
    if ( $custom_loop->have_posts() ) :
    while ( $custom_loop->have_posts() ) : $custom_loop->the_post();
    $post_image = thesis_post_image_info('thumb');
    echo '<div class="post type-post hentry post_box top">';
    echo $post_image['output'];
    echo '<div class="headline_area"><h5 class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h5>';
    echo '<p class="headline_meta"><abbr title="" class="published">' . get_the_date() . '</abbr></p></div>';
    echo '<div class="format_text entry-content"><p>' . get_the_excerpt() . '</p></div>';
    echo '<a href="' . get_permalink() . '">' . '<span class="slider-more-button published">Read More »</span></a>';
    echo '</div>';
    endwhile;
    wp_pagenavi( array( 'query' => $custom_loop ) );
    wp_reset_query();
    endif;
    ?></div> 
    
    </div><?php  
    
            }
        }
    add_action('thesis_hook_after_headline','News');

    I fixed it with this:

    function News(){
    if (is_page('Backyard Blog')) {
    ?>
    <div id= "Blog">
    
    <div id= "BBlog">
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $custom_loop = new WP_Query(array(
      'paged' => $paged,
      'post_type' => 'post',
      'cat' => 1,
      'posts_per_page' => 2,
      'orderby_order'    => 'date'
    ));
    if ( $custom_loop->have_posts() ) :
    while ( $custom_loop->have_posts() ) : $custom_loop->the_post();
    $post_image = thesis_post_image_info('thumb');
    echo '<div class="post type-post hentry post_box top">';
    echo $post_image['output'];
    echo '<div class="headline_area"><h5 class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h5>';
    echo '<p class="headline_meta"><abbr title="" class="published">' . get_the_date() . '</abbr></p></div>';
    echo '<div class="format_text entry-content"><p>' . get_the_excerpt() . '</p></div>';
    echo '<a href="' . get_permalink() . '">' . '<span class="slider-more-button published">Read More »</span></a>';
    echo '</div>';
    endwhile;
    wp_pagenavi( array( 'query' => $custom_loop ) );
    wp_reset_query();
    endif;
    ?></div> 
    
    </div><?php  
    
            }
        }
    add_action('thesis_hook_after_headline','News');

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

  11. Dre4000
    Member
    Posted 1 year ago #

  12. RLL18
    Member
    Posted 11 months ago #

    I can not get it to go to any page but the first one either. However, I am not extremely skilled in PHP, so I don't really know what is going on. Can somebody please help me understand how to make it go to the correct pages?

    http://www.gigglelounge.net

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic