Support » Fixing WordPress » Custom Post Type Pagnation issue

  • I’m currently trying to set it up so that the homepage (static) display the most recent posts, but only their featured image.

    Alongside that, I’m trying to add pagnation to it, which is in most recent order.

    When I use the WP Pagenavi plugin, it only displays “Page 1 of 1” Instead of the rest.

    I’m relatively new to all of this, so any help would be appreciated.

    The code im using is below:

    $thumbnails = get_posts('numberposts=6');
    foreach ($thumbnails as $thumbnail) {
    if ( has_post_thumbnail($thumbnail->ID)) {
    echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
    echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');
    echo '</a>';
    	</div> <!--end of options container_12 grid_8-->
    	<div class="clearboth"></div>
    <?php endwhile; // end of the loop. ?>
    <?php wp_pagenavi(); ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • AFAIK, WP PageNavi only works with query_posts(). Here is an article that shows sample code for paginating any array.

    This article shows the use of the WP function paginate_links() to do the same:

    Pagenavi works with new WP_Query as well, but it can’t work with get_posts(), since that function doesn’t return the necessary pagination information.

    Thanks for the support guys, I tried the first link which vtxyzzy suggested which works a treat, but is there a way for it to pull in JUST the featured image that i’ve set on the post? Or is that not possible…

    My php knowledge in general is a bit rubbish so i’m no really sure where to start…

    Thanks for the quick responses!

    Hi guys, thanks for all the help, but i’ve figured how to pull in the featured image as well.

    Thanks for all your help!


    Ah, sorry or a TRIPLE post but I don’t know how to edit my own comment haha.
    But basically,
    With that custom query in place, is it possible to do the same for catergories?

    As in, I have 7 different types of catergories on my site, but only want x amount of those posts within that catergory, to be displayed when clicked on said catergory, which then also has pagination to display later posts…

    if any of that makes sense!


    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    You were caught in the spam queue. However to edit a post, click on the ‘edit’ link under your avatar within one hour of posting.

    I have used the technique of creating a template for categories that gets the category to show from a Custom Field. You can assign the template to a Page and set the category by adding the Custom Field. This way you have one template for as many categories as you want.

    One problem you might have is that most themes do not ‘stay in category’ inside single.php. See this article for more information:

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Post Type Pagnation issue’ is closed to new replies.