WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Pagnation issue (8 posts)

  1. RForster92
    Member
    Posted 2 years ago #

    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:

    <?php
    $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(); ?>
  2. vtxyzzy
    Member
    Posted 2 years ago #

    AFAIK, WP PageNavi only works with query_posts(). Here is an article that shows sample code for paginating any array.

    http://wordpress.mcdspot.com/2010/05/24/pagination-of-array-custom-query/

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

    http://wordpress.mcdspot.com/2010/11/25/pagination-using-paginate_links/

  3. scribu
    Member
    Posted 2 years ago #

    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.

  4. RForster92
    Member
    Posted 2 years ago #

    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!

  5. RForster92
    Member
    Posted 2 years ago #

    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!

    Solved.

  6. RForster92
    Member
    Posted 2 years ago #

    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!

    Thanks!

  7. 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.

  8. vtxyzzy
    Member
    Posted 2 years ago #

    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:

    http://wordpress.mcdspot.com/2010/06/02/stay-in-category/

Topic Closed

This topic has been closed to new replies.

About this Topic