WP-PageNavi only displaying first page.
-
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]
-
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.
And move the function to be before wp_reset_query() function.
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="https://<?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 »'); ?> </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(); ?>
Using pastebin now: https://pastebin.com/JQYcyTmd
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(); ?>
Got it to work but with the regular <?php wp_pagenavi(); ?>
Just a letter difference in the word ‘paged’…lol wow. Thanks a bunch!
Glad you made it!
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');
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.]
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?
- The topic ‘WP-PageNavi only displaying first page.’ is closed to new replies.