WordPress:仅在今天发布帖子时显示特定 Div
我正在使用 Wordpress 创建一个交易类型网站,每天一次交易类型的内容。基本上,我试图仅根据以下条件显示今天交易的赞助商图像:如果今天的发布日期与服务器相同,则显示赞助商 div 和图像,否则不显示。
我本可以发誓以下代码有效,但现在似乎根本不起作用:
if( date('Yz') == get_the_time('Yz') ):
感谢任何帮助和想法。
I am creating a deals type website with one deal per day type thing using Wordpress. Basically I am trying to show a sponsor image for today's deal only based on the condition that if today's post date is the same as the server, then show the sponsor div and image, otherwise don't show it.
I could have sworn the following code worked, but now doesn't appear to work at all:
if( date('Yz') == get_the_time('Yz') ):
Any help and thoughts are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能只是它在循环之外不起作用的情况。
It might just be a case of it not working outside the loop.
我很感谢你们所有的回复,但我最终自己解决了这个问题。如果有人需要的话,这是解决方案,我相信它会更好,但它也按照我想要的方式工作。
I appreciate all of your replies guys, but I figured this one out myself eventually. Here is the solution if anyone needs it, I am sure it could be better, but it works the way I want it too.