• 0
    down vote
    favorite
    when I click on “older entries” in my home page, it goes to a second link but it shows the same posts. I’m not an expert in PHP but I think I need to modify something in the index.php, this is the full code section that I think I need to modify:

    <div class="container">
        <div class="post_content">
            <div class="home_posts">
                <?php
                    $args2 = array(
                    'post_type' => 'post',
                    'posts_per_page' => 10,
                    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 2),
                    );
                    $query = new WP_Query( $args2 );
                    if ( $query->have_posts() ) :
                        while ( $query->have_posts() ) : $query->the_post();
                            echo '<div class="grid_post">
                                    <h3><a href="'.get_permalink().'">'.get_the_title().'</a></h3>';
                            $type = get_post_meta($post->ID,'page_featured_type',true);
                            switch ($type) {
                                case 'youtube':
                                    echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/'.get_post_meta( get_the_ID(), 'page_video_id', true ).'?wmode=transparent" frameborder="0" allowfullscreen></iframe>';
                                    break;
                                case 'vimeo':
                                    echo '<iframe src="https://player.vimeo.com/video/'.get_post_meta( get_the_ID(), 'page_video_id', true ).'?title=0&byline=0&portrait=0&color=03b3fc" width="500" height="338" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
                                    break;
                                default:
                                    echo '<div class="grid_post_img">
                                                <a href="'.get_permalink().'">'.get_the_post_thumbnail().'</a>
                                            </div>';
                                    break;
                            }
                            echo '<div class="grid_home_posts">
                                        <p>'.dess_get_excerpt(120).'</p>
                                    </div>
                                </div>
                                ';
                        endwhile;
                ?>
        </div>
        <?php
            echo '<div class="load_more_content"><div class="load_more_text">';
                    ob_start();
                        next_posts_link('LOAD MORE',$query->max_num_pages);
                        $buffer = ob_get_contents();
                    ob_end_clean();
                    if(!empty($buffer)) echo $buffer;
                echo'</div></div>';
            $max_pages = $query->max_num_pages;
                wp_reset_postdata();
            endif;
        ?>
        <span id="max-pages" style="display:none"><?php echo $max_pages ?></span>
        </div>
        <?php get_sidebar(); ?>
        <div class="clear"></div>
    </div>
    </div>

    Could it be here:

    $args2 = array(
                    'post_type' => 'post',
                    'posts_per_page' => 10,
                    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 2),
                    );

    Thank you very much. This is my website in case you want to check what I mean: https://www.wha2wear.com

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Assuming you’re displaying 10 posts in the front page, change the $args2 variable to

    $args2 = array(
                    'post_type' => 'post',
                    'posts_per_page' => 10,
                    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 2),
                    'offset' => 10
                    );
    Thread Starter wha2wear

    (@wha2wear)

    Hi David,

    many thanks for your answer. Unfortunately, I still see the same behavior. I asked the question in stackexchange and they gave me different indications but I don’t understand what they. Could you have a look at the question to see if you know what they mean, please?

    Thank you very much!

    Hello wha2wear
    Please replace $args2 with

    $args2 = array(
                    'post_type' => 'post',
                    'posts_per_page' => 5,
                    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                    );

    Hope this will solve your issue

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with older entries in homepage’ is closed to new replies.