wp_paginate with get_posts
-
I am trying to add pagination to a static home page that has blog listings below the home page content. I want to add page numbers below the posts. I am setup to see 4 posts (there are 7 total published posts) but it is not giving me page number for next 3 posts (assuming I should be seeing 1 2). Any help would be VERY appreciated.
[code]
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$postsPerPage = 4;
$postOffset = $paged * $postsPerPage;
$category = 'blog';
$args = array(
'category_name' => $category,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => $postsPerPage,
'offset' => $postOffset,
);
$myposts = get_posts( $args );
if ( $myposts ) { ?>
<div class="home-grid">
<?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<div class="home-grid-content">
<h2><?php the_title( ); ?></h2>
<?php echo get_the_excerpt( ); ?>
</div>
<?php endforeach;
if (function_exists('wp_paginate')):
wp_paginate();
endif;
wp_reset_postdata(); ?>
[/code]The page I need help with: [log in to see the link]
- The topic ‘wp_paginate with get_posts’ is closed to new replies.