Support » Plugin: WP-PageNavi » Hopeless with Custom Post Types

  • morespinach

    (@morespinach)


    The plugin works well in general, but that’s pointless in modern WordPress sites where we have our own CPT custom post types. All the stuff on the web about making sure we used paged properly, or don’t reset_posts, etc, none of those things work. My code:

    
        $args = array(
                'post_type' => 'stories',
                'orderby'   => 'date',
                'order'     => 'DESC',
                'posts_per_page' => (comes from WP options)
            );
        $catPost = get_posts(  $args );
        foreach ($catPost as $post) { 
         .....
    

    It still doesn’t work. I’ve looked at the pinned message on this forum. I’m using paged properly. Is get_posts() a problem and I’m to use the WP_Query function?

    Appreciate any help please.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Actually I got the pagination to show up with two changes, but there’s still a problem.

    The changes:

    1. Changed get_posts() to WP_Query(). Weird WP stuff.

    2. The pagenavi() function called with query as a parameter.

    
    wp_pagenavi( array( 'query' => $the_query ) ); 
    

    So the pagination shows now, but when I click on page 2, it shows me a 404. Any idea why? What is the permalink changing that i need to add it to the WP_Query?

    • This reply was modified 6 months, 4 weeks ago by morespinach.

    Any idea about this? Page 2 either shows 404 or it shows the same content as Page 1. Does this plugin only work with the default blog type posts and pages?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hopeless with Custom Post Types’ is closed to new replies.