【问题标题】:Target only posts in custom wordpress template仅定位自定义 wordpress 模板中的帖子
【发布时间】:2021-12-30 14:22:20
【问题描述】:

以下代码使我的网站崩溃。我试图只定位帖子。不知道为什么。

我的 php 打开和关闭也很好,但我不能让它出现在这里

<?php if(is_single('post')); ?>

    <header>
        test 
    </header>

<?php endif; ?>  

【问题讨论】:

    标签: php wordpress wordpress-theming custom-wordpress-pages


    【解决方案1】:

    is_single() 中不需要说post

    试试这个 - 它应该检查它是否是单身并且它是一个“帖子”

    < ?php if( is_single() && 'post' === get_post_type() ); ? >
    
    < header >
        test 
    </ header >
    < ?php endif; ? >
    

    【讨论】:

    • 没用,但有了更多的 fenageling 我能够让它工作:
    猜你喜欢
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    • 2013-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多