dourui9570 2018-03-05 22:08
浏览 43

Wordpress:url到home.php的所有帖子

I'm develop a theme for WordPress and I have created index.php for the original loop, and home.php for 4 latest posts, now I need to put a link for show all posts, how to I do that?

  • 写回答

2条回答 默认 最新

  • drv16759 2018-03-05 22:40
    关注

    Instead of a link to show all posts, I would use WordPress's have_posts() function inside a while loop (first check to see if there are posts to display, if there are do so, if not exit loop and display other content). You could potentially look at WP's documentation for the function and maybe even glance at file used for the default page template (page.php).

    In order to display only the latest 4 posts, you could simply add a counter variable and end each while loop iteration with an if statement checking to see if count == 4.

    Also, just so you are aware, home.php sometimes takes precedence over index.php so either nest home.php inside an internal directory or call your '4 latest posts' page 'posts.php' or something similar.

    Wordpress documentation: https://codex.wordpress.org/Function_Reference/have_posts

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度