I want to add previous page and next page links on my footer, so I can limit each page to only 5 posts. I DON'T want next post, and previous post. I tried putting this in, and out of the WP loop.. but still not working! I'm brand new to this WordPress stuff. I already implemented next post and previous post for single.php. I want to have previous post, and next post to be used on the index.php and other pages like /categories/, but NOT single.php.
<footer id="home-footer">
<?php posts_nav_link('','<','>'); ?>
<div class="wrapper">
<p id="home-extra">You can find more articles at the <a href="/archive">archive</a>.</p>
</div><!--end .wrapper -->
<div class="footer-wrapper">
<div class="projects">
<h1 id="projects-title">Projects</h1>
<ul class="footer-list">
<li><a href="http://dribbble.com/MatthewKosloski/projects/129666-iOS-Betas">iOS Betas</a></li>
</ul>
</div><!-- end .projects -->
<div class="recent">
<h1 id="recent-title">Recent Posts</h1>
<ul class="footer-list">
<?php
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> ';
}
?>
</ul>
</div><!-- end .recent -->
<div id="dribbble"><h1 id="recent-title">What i'm working on</h1></div>
<script type="text/javascript" src = "https://halfcourtshot.googlecode.com/svn/tags/1/js/half-court-shot.jsapp.mh.min.js"></script>
<script type="text/javascript">var hcs = new HalfCourtShot({ jersey: "matthewkosloski", shots: 3, goal: 'dribbble' });</script>
</div><!-- end .footer-wrapper -->
<div class="note-wrapper">
<p id="note">© 2013 Matthew Kosloski</p>
</div><!-- end .note-wrapper-->
</footer>
in your admin settings > Reading (wp-admin/options-reading.php) change the posts per page count to 5
and for the links you're writing it wrong as per the codex
try this
<?php posts_nav_link('','<','>'); ?>
UPDATE:
You can add this if/else statement to show different on single or index
<?php if(is_single()) { // single-view navigation ?>
<?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php previous_post_link('%link', '<'); ?> | <?php next_post_link('%link', '>'); ?>
<?php endwhile; endif; ?>
<?php } else { // archive view navigation ?>
<?php posts_nav_link('','<','>'); ?>
<?php } ?>
see more help here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.