站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Adding Post Feeds to the Header
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
==The Loop== So we've got our link, and it has the key fields replaced with code that will fill them automatically. But we can't just use the variables anywhere. They must be within '[[WordPress:The Loop]]'. Read more about The Loop at [[WordPress:The Loop|this link]]. If you've come back completely blasted - don't worry. It isn't nearly as complex as the article might make out. 我们得到了链接,将key fields替换为代码,代码会自动地填进。但是我们不能够在任何位置使用变数。我们必须在'[[WordPress:The Loop|The Loop]]'内使用变数。在[[WordPress:The Loop|这个链接]]上阅读关于Loop的内容。如果你沮丧地返回了-不要担心。这个操作并不完全像文章中所描述地那样简单。 Ideally we would add our code to the existing Loop, the one that already provides our posts, comments, and whatnot. While that would work in some browsers, it is completely the wrong place for what we are trying to do. The default Loop is entirely within the body of the page, and <tt>link</tt> elements belong in the head. It would be very bad practice to add the code to the body, and cause all sorts of problems. 理想话地,我们会将代码添加到当前的Loop,Loop已经提供我们的文章,评论,以及其它内容。虽然这在同一个浏览器中能够运行,但是这并不是我们试图操作的位置。默认Loop完全在网页主体之内,而且<tt>链接</tt>在标头。将代码添加到网页主体非常不好,会导致许多问题。 So we need a new Loop. Fret not, it's easy. 因此我们需要一个新的Loop。不要烦恼,这很简单: <tt><?php while (have_posts()) : the_post(); ?> <?php endwhile; ?></tt> <tt><?php while (have_posts()) : the_post(); ?> <?php endwhile; ?></tt> There you have it, a secondary Loop. Stick our code between those two lines and it will work just fine. 在第二个Loop中,你可以添加Loop。将我们的代码粘贴在这两行之间,就能够运行了。 There's only one problem. Because of the way The Loop works, if we leave it at that we will have the right feed in the document head, but the post displayed in the body of the page, the thing you actually read, will be the next one in the database. This won't do at all. Luckily the fix is once again simple: 这里只有一个问题。因为Loop的运行的方式不同,如果我们保留那种方式,在文件标头我们会有合适的feed,但是文章在网页的主题中显示,你真正阅读的内容,是数据库中的下一篇文章。这行不通。幸运地是,解决方法仍然很简单: <tt><?php rewind_posts(); ?></tt> Our loop is now complete. <tt><?php rewind_posts(); ?></tt> 现在我们的loop完成了。
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)