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.
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.
solved my problem by removing
<?php query_posts('posts_per_page=3') ?>
and tried limiting posts from Settings->Reading. Thanks