I have my own custom post type, and 15 items there.
This code shows all the items:
<?php $loop = new WP_Query( array( 'post_type' => 'my_post_type', 'posts_per_page' => 15 ) );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
(...)
When I change posts_per_page to "5" there should be 3 pages, but it displays only 5 items and there are no other pages (or at least I don't know how to access them).
This code displays nothing:
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
{menu or any html code}
<?php endif; ?>
Maybe I do something wrong? I have the whole code/loop in page-myposttype.php file.
I've tried this code:
$temp = $wp_query;
$loop= null;
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$loop = new WP_Query( array(
'post_type' => 'my_post_type',
'paged' => $paged,
'posts_per_page' => 2 ) );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
But no luck... When I type wordpress/my_post_type/page/2 (page/3 etc.) manually I see other pages and they work & look fine. But I'm unable to echo the default navi... :(
$loop
, but you check the number of pages of$wp_query
.$wp_query
will contain the default query, which is probably a page in your case?