Wordpress 多循环条件冲突
好吧,我有两个循环,在正文中和在侧边栏中。我还在页脚中有一个生成另一个循环的条件语句。我遇到的问题是在页脚中使用条件语句。由于侧边栏中的循环是最后调用的,因此 Wordpress 在页脚的条件语句中使用其变量,并导致其返回 false。
也许有某种方法可以使主体 $_GLOBAL 中的某些变量处于循环状态,这样我以后就可以使用它,并且不会与侧栏中的循环发生冲突?
谢谢
Alright I have two loops going, on in the body and on in the sidebar. I also have a conditional statement in the footer that generates another loop. The problem I'm running into is the use of the conditional statement in the footer. Because the loop in the sidebar was called last, Wordpress is using its variables in the conditional statement in the footer, and causing it to return false.
maybe there's some way to make some of the variables in loop in the body $_GLOBAL, that way I can use it later on and not have it conflict with the loop in the sidebar?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行一个新的查询;您可以在标准 WP 循环中运行任意数量的代码。我不知道您在当前循环中正在做什么,但这是一个新查询的示例,它可以与主 WP 循环以及查询的其他实例共存:
另请参阅 函数参考/WP 查询 « WordPress Codex 和 函数参考/wp重置查询 « WordPress Codex
Run a new query; you can run as many as you want within the standard WP loop. I don't what you're doing in your current loops, but this is an example of a new query that can coexist with the main WP loop as well as other instances of the query:
Also see Function Reference/WP Query « WordPress Codex and Function Reference/wp reset query « WordPress Codex