【问题标题】:Display Wordpress widget on a post page from a certain category在某个类别的帖子页面上显示 Wordpress 小部件
【发布时间】:2012-02-17 08:56:32
【问题描述】:

我正在使用 wordpress 插件 Widget Logic 来选择小部件的显示位置。 它使用 wordpress 条件标签。

我的问题是:什么 wordpress 条件标签可用于在特定类别内的单个帖子页面上显示? is_category() 仅在帖子存档页面上显示,而不是在查看同一类别的帖子时显示。

【问题讨论】:

    标签: wordpress conditional widget conditional-statements


    【解决方案1】:
    if (is_category( array( 9, 'category 1', 'category 2' ) ) || is_single()) {
        // your code here
    }
    

    当显示的帖子类别是term_ID 9,或slug category 1,或名称category2并且是单页时返回true

    http://codex.wordpress.org/Conditional_Tags#Introduction

    【讨论】:

      猜你喜欢
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-22
      相关资源
      最近更新 更多