wordpress pagination doesn't show -
******edit*******
this code posts:
<?php if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } query_posts('posts_per_page=3&paged=' . $paged); $args = array ( 'posts_per_page' => 3, $offset = $paged*$pages, 'post_type' => array('post','project'), 'meta_key' => '_thumbnail_id' );
the navigation numbers show, , goes page/2 new posts didn't show.
i build local wordpress website test. add pagination in wordpress. pagination don't show up. code:
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = array ( 'posts_per_page' => 3, 'offset' => 0, 'post_type' => array('post','project'), 'meta_key' => '_thumbnail_id', 'paged' => $paged ) $home_recent = new wp_query( $args ); if( $home_recent ->have_posts() ) : while( $home_recent ->have_posts() ) : $home_recent ->the_post(); $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'full' ); $post_type = get_post_type( $post->id ); ?>
this if posts.
this function:
function pagination($pages = '', $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo "<div class=\"pagination\"><span>page ".$paged." of ".$pages."</span>"; if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« first</a>"; if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ previous</a>"; ($i=1; $i <= $pages; $i++) { if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) { echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>"; } } if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">next ›</a>"; if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>last »</a>"; echo "</div>\n"; } }
and show pagination:
<?php } endwhile; if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } endif; wp_reset_postdata(); ?>
butt shows nothing 3 posts. code wrong or miss things?
julian
Comments
Post a Comment