【问题标题】:How would I detect if I was on the forums page我如何检测我是否在论坛页面上
【发布时间】:2012-11-06 16:07:37
【问题描述】:

我已经制作了一个 WordPress 主题,并且已经设法检测是否安装了 bbpress,并且我想要一个正确的方法来查看我是否在论坛、主题列表或主题页面上。

据我了解,网址结构如下:

  • ?post_type=论坛
  • ?forum=test-2
  • ?topic=test

对于一个非常基本的安装,不使用子表单等。 我的问题是,我会使用 GET 和/或 POST,还是缺少一些内置的 wordpress 功能?

我想这样做:

if('forum' == get_post_type() || 'topic' == get_post_type()){
    echo "I am here"; exit;
}

但这没有用。所以....我想知道我错过了什么吗?

【问题讨论】:

    标签: wordpress wordpress-theming bbpress


    【解决方案1】:

    不确定这是否仍然是一个问题,但这对我有用(WP3.x,bbPress 插件 2.x);

    $posttype=get_post_type(); 
    
    if (($posttype=='forum')||($posttype=='topic')) 
      { echo "I am here"; }
    

    【讨论】:

      猜你喜欢
      • 2010-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-10
      相关资源
      最近更新 更多