【问题标题】:wordpress - if bbpress show the_content()wordpress - 如果 bbpress 显示 the_content()
【发布时间】:2014-01-14 17:39:17
【问题描述】:

这就是我在 wordpress 中调用我的内容的方式:

<?php
    if ( is_singular() ) {
    the_content();
    } else {
    the_excerpt();
    }
?>

但是我也不能调用 bbpress,因为 bbpress 不支持 the_excerpt()。现在我想添加另一个 if else 或类似的东西来调用 bbpress 内容。

<?php
    if ( is_singular() ) {
    the_content();
    } else {
    the_excerpt();
    }
    ifelse ( is_bbpress() ) {
    the_content();
    }
?>

我知道上面的代码是错误的,这就是我问这个问题的原因! :)

我们将不胜感激。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    这就是你要找的吗?

    <?php if ( is_singular() || is_bbPress() ) {
             the_content();
          } else {
             the_excerpt();
    } ?>
    

    【讨论】:

      【解决方案2】:

      我在这里找到它:

      <?php
          if ( is_singular() ) {
          the_content();
          }
          elseif ( is_bbpress() ) {
          the_content();
          }
          else {
          the_excerpt();
          }
      ?>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-04
        • 2012-01-04
        • 2020-07-11
        相关资源
        最近更新 更多