Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何使它成为可能,如果没有帖子,我希望能够隐藏控制最新博客帖子的 DIV,只有当有人在博客上发布某些内容时才会出现它们。
有点像 joomla 中的职位,但在这种情况下,我使用的是 wordpress
您可以使用该have_posts()函数来检测循环中是否有任何帖子,并据此执行条件。
have_posts()
扩展ceejyaoz的答案
if(have_posts()) { //... do HTML in here }
如果没有帖子,则 HTML 以及div您正在谈论的可能不会出现。如果没有帖子,您甚至可以对自定义消息使用 else 语句。
div