Support » Plugin: WP-PageNavi » 404 after page 20

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    do you have the same problem if you temporarily activate the default theme Twenty Thirteen?

    if you assume it is theme related, have you contacted your theme’s developer for support?
    http://codex.wordpress.org/Forum_Welcome#Commercial_Products

    alchymyth thank you for always be there for me. you the best.

    here’s the code that I use

    <?php get_header(); ?>
    <div class="b_content clearfix" id="main">
    
        <!-- Start content -->
        <div class="b_page clearfix">
    
    <div class="entry-content"><div class="page_posts"><ul>
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'post', 'posts_per_page' => 24, 'paged' => $paged );
    $wp_query = new WP_Query($args);
    while ( have_posts() ) : the_post(); ?>
    
    <li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'Related-Thumb' ); ?><?php the_title(); ?></a></div></li>
    
    <?php endwhile; ?>
    </ul>
        </div>
    </div>
    <?php wp_pagenavi();
    wp_reset_query(); ?>
        </div>
    </div>
    </body>
    </html>

    If i put this code inside a page template it work fine but on front page template it does he 404 after page 20

    Any ideas

    Michael

    (@alchymyth)

    Forum Moderator

    to change the query of a main index page, use 'pre_get_posts' instead of WP_Query()http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    please contact your theme’s developer for support; commercial themes are not supported by this forum.

    actually they don’t support modifications. I made a lot
    if you mean like that, it gives me a error

    <?php get_header(); ?>
    <div class="b_content clearfix" id="main">
    
        <!-- Start content -->
        <div class="b_page clearfix">
    
    <div class="entry-content"><div class="page_posts"><ul>
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'post', 'posts_per_page' => 24, 'paged' => $paged );
    $wp_query = pre_get_posts($args);
    while ( have_posts() ) : the_post(); ?>
    
    <li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'Related-Thumb' ); ?><?php the_title(); ?></a></div></li>
    
    <?php endwhile; ?>
    </ul>
        </div>
    </div>
    <?php wp_pagenavi();
    wp_reset_query(); ?>
        </div>
    </div>
    </body>
    </html>

    Fatal error: Class ‘pre_get_posts’ not found in /home/giantgag/public_html/wp-content/themes/megusta/front-page.php on line 11

    Michael

    (@alchymyth)

    Forum Moderator

    how to implement the ‘pre_get_posts’ action:

    remove this section from front-page.php:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'post', 'posts_per_page' => 24, 'paged' => $paged );
    $wp_query = pre_get_posts($args);

    and add this into functions.php:

    function custom_home_page_posts_per_page( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
            return;
    
        if ( is_home() ) {
            // Display 24 post for the original blog archive
            $query->set( 'posts_per_page', 24 );
            return;
        }
    }
    add_action( 'pre_get_posts', 'custom_home_page_posts_per_page', 1 );

    thank you

    I just removed that piece

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'post', 'posts_per_page' => 24, 'paged' => $paged );
    $wp_query = pre_get_posts($args);

    and it worked.
    Probably already in my theme functions

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘404 after page 20’ is closed to new replies.