WordPress not showing pagination links

In my WordPress Index.html I am pulling out the 3 latest posts by using

?php query_posts('posts_per_page=3') ?

?php while(have_posts()) : the_post(); ?

   //rest of the post related data

?php endwhile; wp_reset_query();  ?
?php do_action('show_navigation');

after that I want to fetch the next 3 or previous 3 posts and for this I am trying

if ( ! function_exists( 'theme_content_navigation' ) ) {
    function theme_content_navigation( ) {
        global $wp_query;

        if ( $wp_query-max_num_pages  1 ) { ?
            nav class="navigation" role="navigation"
                div class="nav-previous"?php next_posts_link( '' ); ?/div
                div class="nav-next"?php previous_posts_link( '' ); ?/div
            /nav
        ?php 
        }
    }
}



add_action('show_navigation', 'theme_content_navigation');

this code in functions.php.

Right now I have 4 posts and three of them are displaying in my index.php but I am unable to see the navigation links to fetch next posts and replace the existing ones in index.php. Kindly suggest me how to fetch next or previous posts.

Topic next-post-link previous-post-link functions pagination Wordpress

Category Web


solved my problem by removing

<?php query_posts('posts_per_page=3') ?>

and tried limiting posts from Settings->Reading. Thanks

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.