【问题标题】:Custom conditional tags in wordpresswordpress 中的自定义条件标签
【发布时间】:2012-01-31 08:39:52
【问题描述】:

大家都知道wordpress中的条件标签,它们是这样的:

is_archive () , is_single()

现在我正在寻找一个条件标签来检查是否正在显示术语的存档页面或术语列表。像这样:

is_archive($term_name) OR is_archive(array(term1,term2,term3))

我的问题是,is wordpress have a conditional tag for this functionality ?are we can create a new conditional tag in wordpress ?

提前致谢

【问题讨论】:

    标签: wordpress tags conditional


    【解决方案1】:

    你可以看到条件标签的完整列表here

    is_tag,这样使用:

    is_tag( array( 'sharp', 'mild', 'extreme' ) ) 
    

    这些函数返回 true,因此您可以像下面这样使用它们来构建更复杂的条件:

    if (is_archive($term_name) || is_tag( array( 'sharp', 'mild', 'extreme' ) ) {
     // do something
    }
    

    【讨论】:

    • 谢谢,但is_archive($term_name) 没有给出任何论据,请先阅读其法典
    猜你喜欢
    • 1970-01-01
    • 2012-04-25
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-20
    相关资源
    最近更新 更多