Php 如何在Wordpress上添加上一页和下一页文章?
我想在我的页脚上添加上一页和下一页链接,这样我就可以将每页限制为5篇文章。我不想要下一篇文章,也不想要上一篇文章。我试着把这个放进,然后从WP循环中退出。。但还是不行!我对WordPress的东西是全新的。我已经为single.php实现了next post和previous post。我希望在index.php和其他页面(如/categories/)上使用上一篇文章和下一篇文章,但不要使用single.phpPhp 如何在Wordpress上添加上一页和下一页文章?,php,wordpress,Php,Wordpress,我想在我的页脚上添加上一页和下一页链接,这样我就可以将每页限制为5篇文章。我不想要下一篇文章,也不想要上一篇文章。我试着把这个放进,然后从WP循环中退出。。但还是不行!我对WordPress的东西是全新的。我已经为single.php实现了next post和previous post。我希望在index.php和其他页面(如/categories/)上使用上一篇文章和下一篇文章,但不要使用single.php <footer id="home-footer">
<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>
您可以在网站上找到更多文章
项目
最近的职位
我在做什么
var hcs=新半场投篮({泽西岛:“马修科斯洛斯基”,投篮:3次,进球:“带球”});
©;2013年马修·科斯洛斯基
在您的管理设置>阅读(wp admin/options Reading.php)中,将每页文章数更改为5
对于链接,您根据
试试这个
<?php posts_nav_link('','<','>'); ?>
更新:
您可以添加此if/else语句以在单个或索引上显示不同的
<?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 } ?>
|
请参阅更多帮助文章第二页的“上一页”和“下一页”应该链接到什么。我想限制第一页有5个可湿性粉剂贴子,然后在第二页继续其余的。它必须在一个循环中吗?因为它没有出现。可能是因为它在footer-home.php中?我对不同的页面有不同的页脚,我不知道这是否会影响它。我在上面发布了我的footer-home.php代码。因此在第129行我将值1改为5?|输出职位的名称。我只需要这样做::我需要把它放在上面的代码中作为footer home。php@MatthewKosloski再次更新。您必须在函数中运行字符串才能获得不同于默认值的自定义文本