• Resolved slaifer

    (@slaifer)


    Hello i’m currently using custom post type on a page template, this is the code :

    <?php
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$loop = new WP_Query( array( 'post_type' => 'myposttype', 'posts_per_page' => 4, 'paged'=>$paged ) ); ?>  
    
    	<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    	.....loop code...
    
    <?php endwhile; ?>
    
    	<?php wp_pagenavi(); ?>

    If i use the normal pagination everything works but if i use

    <?php wp_pagenavi(); ?>

    nothing shows on my page… how to fix this ? thanks

    EDIT : i’ve checked in wp page navi settings the option

    “Show navigation even if there’s only one page.”

    and now it shows some sort of navigation on my page but it says that there is only 1 page but it’s not true, there are 2 page… what’s going on ?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author scribu

    (@scribu)

    It doens’t work because it checks the global $wp_query.

    In the development version (2.74-alpha), you can do this:

    wp_pagenavi( array( 'query' => $loop ) );

    Thread Starter slaifer

    (@slaifer)

    thank you so much now it works :).

    Hi,

    I’m also calling custom post types. I got mine to show up, but when you click on page2 or page3 of pagenavi I get a 404 page.
    http://www.monsterwheellaboratories.com/grandprix/pit-crew

    I’m using this code:

    <?php $my_query = new WP_Query( array( 'post_type' => 'pit-crew', 'posts_per_page' => 4, 'paged' => get_query_var('paged') ) ); ?>
    			<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
                    <div id="card-wrap">
                        <img src="<?php echo get_post_meta($post->ID, "crewcard", true); ?>" alt="<?php the_title(); ?>" />
                    </div>
                <?php endwhile; ?>
                <?php wp_pagenavi( array( 'query' => $my_query ) ); ?>
                <?php wp_reset_postdata(); ?>

    If anyone can help me out it would be greatly appreciated.
    Thanks in advance.

    wish i could help @dying2live… my issues with pagenavi are tht it is not even showing he full amount of items in my custom post type. keeps saying page 1 of 1 but there are at least 20 items on my custom post type.

    any help scribu would be great. i’m going to post a more in depth description here in the forums… thnx

    @sacredpractice:
    It turns out my code was working correctly. The problem was I was using custom permalinks /%category%/%postname% and pagenavi was not recognizing it. All I did was revert back to default permalinks and save the changes. I refreshed my browser then went back in to permalinks and and rechecked custom and entered in /%category%/%postname% and save the change. after I did that everything was working perfectly.

    I hope that that helps you.

    thanks @dying2live

    i tried what you suggest but still only get “Page 1 of 1”!

    i am using a post template created from the single.php (template called single-events.php)… maybe this the issue? I am not using a page template instead a post template for my custom post type items?

    here is a link to my code and problem with pagenavi:

    http://wordpress.org/support/topic/pagenavi-plug-in-is-not-working-in-custom-post-types?replies=1#post-2004429

    any help is appreciated. thnx in advance.

    Thanks scribu

    For those who have 404 problems with a custom post type indexing template, try to set ‘with_front’ to true:

    'rewrite' => array( 'slug' => 'portfolio', 'with_front' => true),

    The trick is to ensure your page template does not have the same slug as the custom post type slug.

    I took me some time to figure it out.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP-PageNavi] Wp page navi on custom post type page’ is closed to new replies.