WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
[resolved] 404 after page 20 (7 posts)

  1. bondigor69
    Member
    Posted 9 months ago #

    hey guys I get 404 errors only after page 20 ??
    Here's my site
    Giantgag

    http://wordpress.org/plugins/wp-pagenavi/

  2. alchymyth
    Forum Moderator
    Posted 9 months ago #

    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

  3. bondigor69
    Member
    Posted 9 months ago #

    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

  4. alchymyth
    Forum Moderator
    Posted 9 months ago #

    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.

  5. bondigor69
    Member
    Posted 9 months ago #

    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

  6. alchymyth
    Forum Moderator
    Posted 9 months ago #

    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 );
  7. bondigor69
    Member
    Posted 9 months ago #

    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

Reply

You must log in to post.

About this Plugin

About this Topic