سؤال

So far this is the code I have in my index.php file:

<?php 

        // Custom code to offset posts and setup pagination
        $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

        $ppp = get_option( 'posts_per_page' );      

        if ( $page == 1 )
            $offset = 6;
        else
            $offset = 6 + ( $page - 1 ) * $ppp;

        $args = array(
          'posts_per_page' => $ppp,
          'offset'     =>  $offset,
        );
        $offset_query = new WP_Query ( $args );

?>

At this point everything works fine except that there is an extra page with no posts on the site. Apparently this occurs because found_posts doesn't account for offset and so found_posts thinks there are more posts and adds an extra page.

So how would I deduct the offset from the found_posts value so that the extra page doesn't occur. Or, how would I just get rid of the extra page that is showing up.

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top