• I’m fairly new to wordpress and am having some difficulty in getting the wp_pagenavi to display on my custom posts page. I’m currently using the duplex theme for our layout. Below is the code use to display the posts on that particular page as well as the wp_pagenavi code

    <?php $finish = 1; ?>
                                <?php $start = 2; ?>
                                <?php
    							$query = new WP_Query();
    							$query->query('cat='. $cat_ID);
    							$finish = 1;
    							$start = 4;
    							$post_count = $query->post_count; ?>
    
                                <?php wp_reset_query(); ?>
    
                                 <?php query_posts( 'post_type=sermons'); ?>
    
                                <?php if (have_posts()) : while (have_posts()) : the_post();?>
    
                                <?php if(is_multiple($start, 2)) : ?>
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
                                            <div class="nav-next"><?php next_posts_link(__('&larr; Older Entries', 'framework')) ?></div>
                                            <div class="nav-prev"><?php previous_posts_link(__('Newer Entries &rarr;', 'framework')) ?></div>
                                        <?php } ?>

    I’m sure that there is something simple that I am missing in the loop. I’m just not proficient enough to decipher the issue.

    Thank you in advance.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Simply add:

    <?php wp_pagenavi(); ?>

    To your custom page where you want the page navigation to appear.

    Probably just above <?php if (have_posts()) : ….???? or in the Template this uses

    Thread Starter ddeuster

    (@ddeuster)

    Sorry that didn’t resolve the issue. The conditional if statement is already adding that bit of code. I also tried replacing it with what you suggested to no avail.

    What conditional if statement would that be?

    Thread Starter ddeuster

    (@ddeuster)

    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>

    Thread Starter ddeuster

    (@ddeuster)

    Update: If It is placed directly below the code as you suggested it will display. However, when it is moved to the appropriate location on the page it disappears. I’m attaching the full code of the page for you.

    <?php /* Template Name: Sermons Custom Post Type Archive */
    get_header(); ?>
    
    <?php $cat_ID = get_query_var('cat'); ?>
    <div id="the_body">
    
            <div class="container_12">
    
            	<div id="single_bg" class="grid_12">
    
                    <div class="grid_12 alpha omega">
    
                            <div id="nav">
    
    							<?php if ( has_nav_menu( 'primary-menu' ) ) : /* if menu location 'primary-menu' exists then use custom menu */ ?>
                                <?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'menu_class' => 'sf-menu', 'container' => '' ) ); ?>
                                <?php else : /* else use wp_list_categories */ ?>
                                <ul class="sf-menu">
                                    <?php wp_list_categories( array( 'exclude' => $tz_primary_nav_exclude, 'title_li' => '' )); ?>
                                </ul>
                                <?php endif; ?>
    
                                <div class="clear"></div>
    
                            </div><!--nav-->
    
                        </div><!--grid_12-->
    
                        <div class="grid_12 alpha omega">
                        	<div class="gap"></div>
                        </div>
    
                        <div id="archive">
    
                            <div class="grid_8 alpha">
    
                            	<div class="grid_8 alpha omega">
    
                                    <?php /* Get author data */
    								 if(get_query_var('author_name')) :
    								 $curauth = get_userdatabylogin(get_query_var('author_name'));
    								 else :
    								 $curauth = get_userdata(get_query_var('author'));
    								 endif;
    								?>
    
    								<?php if ( function_exists('yoast_breadcrumb') ) : ?> <div class="breadcrumb"><p><?php yoast_breadcrumb(); ?></p></div><!--breadcrumb-->
    
    								<?php else : /* if yoast_breadcrumb is not available, use a generic title */ ?> 
    
                                    <div class="archive_title">
    								<?php /* If this is a category archive */ if (is_category()) { ?>
    									<h1><?php printf(__('All posts in %s', 'framework'), single_cat_title('',false)); ?></h1>
    								<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    									<h1><?php printf(__('All posts tagged %s', 'framework'), single_tag_title('',false)); ?></h1>
    								<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    									<h1><?php _e('Archive for', 'framework') ?> <?php the_time('F jS, Y'); ?></h1>
    								 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    									<h1><?php _e('Archive for', 'framework') ?> <?php the_time('F, Y'); ?></h1>
    								<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    									<h1><?php _e('Archive for', 'framework') ?> <?php the_time('Y'); ?></h1>
    								<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    									<h1><?php _e('All posts by', 'framework') ?> <?php echo $curauth->display_name; ?></h1>
    								<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    									<h1><?php _e('Blog Archives', 'framework') ?></h1>
    								<?php } ?>
                                    </div><!--archive_title-->
    
    								<?php endif; ?>
    
                                    <div class="description"><?php echo category_description(); ?></div>
    
                                    <div class="clear"></div>
    
                                </div><!--grid_8 alpha-->
    
                                <?php $finish = 1; ?>
                                <?php $start = 2; ?>
                                <?php
    							$query = new WP_Query();
    							$query->query('cat='. $cat_ID);
    							$finish = 1;
    							$start = 4;
    							$post_count = $query->post_count; ?>
    
                                <?php wp_reset_query(); ?>
    
                                 <?php query_posts( 'post_type=sermons'); ?>
                                 <?php wp_pagenavi(); ?>
                                <?php if (have_posts()) : while (have_posts()) : the_post();?>
    
                                <?php if(is_multiple($start, 2)) : ?>
    
                                <div class="box_item">
                                <?php endif; ?>
    
                                    <div class="box <?php if(is_multiple($start, 2)) : ?>first<?php endif; ?>">
    
                                        <div class="box_wrap">
    
                                            <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) : /* if post has post thumbnail */ ?>
    
                                            <div class="image"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('category-thumbnail'); ?></a></div>
                                            <?php else: ?>
            <div class="image"><a href="<?php the_permalink(); ?>"><img src="<?php echo get_bloginfo('template_url') . '/images/ogf-default-thumb.gif'; ?>" /></a></div>
                                            <?php endif; ?>
                                            <div class="sermon-icons">
                                            <ul class="services">
    
            <?php if($cust['word_file'][0]): ?>
          <li><img src="<?php echo get_bloginfo('stylesheet_directory') . '/images/ico1.png'; ?>" width="21" height="20" alt="Doc" /></li><?php endif; ?>
          	<?php if($cust['pdf_file'][0]): ?>
          <li><img src="<?php echo get_bloginfo('stylesheet_directory') . '/images/ico2.png'; ?>" width="21" height="20" alt="Doc" /></li><?php endif; ?>
          	<?php if($cust['power_point_document'][0]): ?>
          <li><img src="<?php echo get_bloginfo('stylesheet_directory') . '/images/ico3.png'; ?>" width="21" height="20" alt="Doc" /></li><?php endif; ?>
          	<?php if($cust['vimeo_link'][0]): ?>
          <li><img src="<?php echo get_bloginfo('stylesheet_directory') . '/images/ico4.png'; ?>" width="21" height="20" alt="Doc" /></li><?php endif; ?>
          	<?php if($cust['download_link'][0]): ?>
          <li><img src="<?php echo get_bloginfo('stylesheet_directory') . '/images/ico5.png'; ?>" width="21" height="20" alt="Doc" /></li><?php endif; ?>
          	<?php if($cust['download_link'][0]): ?>
          <li><img src="<?php echo get_bloginfo('stylesheet_directory') . '/images/ico6.png'; ?>" width="21" height="20" alt="Doc" /></li><?php endif; ?>
    
              </ul>
                         </div>                   <div class="details">
    
                                                <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
    
                                                <div class="date"><?php the_time( get_option('date_format') ); ?>, <?php comments_popup_link(__('No Comments', 'framework'), __('1 Comment', 'framework'), __('% Comments', 'framework')); ?></div>
    
                                                <div class="excerpt">
                                                    <p><?php echo substr(get_the_excerpt(), 0, 120); ?>
                                                       <?php if(strlen(get_the_excerpt()) > 120) : ?>...<?php endif; ?> </p>
                                                </div><!--excerpt-->
    
                                            </div><!--details-->
    
                                        </div><!--box_wrap-->
    
                                        <div class="clear"></div>
    
                                    </div><!--box-->  
    
                                <?php if(is_multiple($finish, 2) || $post_count == $finish) : ?>
                                </div><!--box_item-->
                                <?php endif; ?>
    
                                <?php $start++; ?>
                                <?php $finish++; ?>
                                <?php endwhile; else: ?>
    
                                <div class="grid_8 alpha omega">
    
                                    <div class="archive_title"><h1><?php _e('Error 404 - Not Found', 'framework') ?></h1><div class="clear"></div></div>
    
                                    <div class="no">
    
                                        <p><?php _e("Sorry, but you are looking for something that isn't here.", "framework") ?></p>
                                        <?php get_search_form(); ?>
    
                                        <div class="clear"></div>
    
                                    </div>
                            	</div>
                                <?php endif; ?>
    
                                <?php wp_reset_query(); ?>
    
                                <div class="grid_8 alpha omega">
    
                                	<div class="pagination">
    
                                        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
                                            <div class="nav-next"><?php next_posts_link(__('&larr; Older Entries', 'framework')) ?></div>
                                            <div class="nav-prev"><?php previous_posts_link(__('Newer Entries &rarr;', 'framework')) ?></div>
                                        <?php } ?>             
    
                                        <div class="clear"></div>
    
                                    </div>
    
                                </div><!--grid_8 alpha omega-->
    
                            </div><!--grid_8-->
    
                            <div class="clear"></div>
    
                        </div><!--archive-->
    
                    	<div class="grid_4 omega">
    
                            <?php get_sidebar(); ?>
    
                    	</div><!--grid_4-->
    
                    	<div class="clear"></div>
    
                	</div><!--page_bg-->
    
               		<div class="clear"></div>
    
            	</div><!--container_12-->
    
       		</div><!--the_body-->
    
    <?php get_footer(); ?>

    try moving

    <?php wp_reset_query(); ?>

    below the wp_pagenavi part, and, if you only want the wp_pagenavi, remove the conditional, all you need is

    <?php wp_pagenavi(); ?>

    So change the code at reset query From:

    <?php wp_reset_query(); ?>
    
                                <div class="grid_8 alpha omega">
    
                                	<div class="pagination">
    
                                        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
                                            <div class="nav-next"><?php next_posts_link(__('&larr; Older Entries', 'framework')) ?></div>
                                            <div class="nav-prev"><?php previous_posts_link(__('Newer Entries &rarr;', 'framework')) ?></div>
                                        <?php } ?>             
    
                                        <div class="clear"></div>
    
                                    </div>
    
                                </div><!--grid_8 alpha omega-->

    To:

    <div class="grid_8 alpha omega">
    <div class="pagination">
    <?php wp_pagenavi(); ?>
    </div>
    <?php } ?>
    <div class="clear"></div>
    </div>
    </div><!--grid_8 alpha omega-->
    <?php wp_reset_query(); ?>

    (I cleaned it up a bit for readability)

    Thread Starter ddeuster

    (@ddeuster)

    Still a no go

    Please provide a site link where above code change is active.

    Thread Starter ddeuster

    (@ddeuster)

    Thread Starter ddeuster

    (@ddeuster)

    Getting close, just having issues with the page recognition now.

    Re-save/Enable permalinks.

    Thread Starter ddeuster

    (@ddeuster)

    Sorry, still no success.

    Please realize that each question on the way to helping you was a troubleshooting step. Thank you for using WP and good luck.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘wp_pagenavi not displaying on Custom Post Type Page’ is closed to new replies.