WordPress posts pagination

I’am creating a website at WordPress and in my website there exist a post type called “news”. What I ask for is I’m showing 5 posts in a page but I couldn’t show the “next page” button. My code is below, if anyone can help.

<div class="row10 offset1">
    <div class="news">
        <?php
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $args = array( 'post_type' => 'news', 'posts_per_page' => 5, 'paged' => $paged );
        $loop = new WP_Query( $args );
        while ( $loop->have_posts() ) : $loop->the_post(); ?>

            <div class="row-fluid">
                <div class="well-small">
                    <?php   the_title();        ?>
                    <?php   the_content();      ?>
                    <?php  the_date("d.m.Y");     ?>
                </div>

            </div>
            <?php
            endwhile;
        ?>
    </div>
    <div class="pull-right">
        <ul class="pager">
            <li> <?php echo previous_posts_link();?></li>
            <li><?php echo next_posts_link();?></li>
        </ul>
    </div>
    <div class="clearfix"></div>
</div>

Related posts

Leave a Reply

1 comment

  1. I’ve solved my problem, but I don’t know how it happened. =) I’ve added query_posts($args); and it worked properly.

    <div class="span10 offset1">
        <div class="">
            <?php
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args = array( 'post_type' => 'haber', 'posts_per_page' => 3, 'paged' => $paged );
            $loop = new WP_Query( $args );
    
            query_posts($args);  <--- I added this line and it worked --->
    
            while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
                <div class="row-fluid">
    
                    <div class="well-small">
                        <?php   the_title();       ?>
                        <?php   the_content();     ?>
                        <?php  the_date("d.m.Y");    ?>
                    </div>
    
                </div>
                <?php
                endwhile;
            ?>
        </div>
        <div class="pull-right">
            <ul class="pager">
                <li> <?php previous_posts_link("Geri"); ?></li>
                <li> <?php next_posts_link("Ä°leri"); ?></li>
            </ul>
        </div>
        <div class="clearfix"></div>
    </div>