Wordpress - 如果 is_plugin 函数?

Wordpress - if is_plugin function?

所以,我一直在尝试一些事情,但我无法弄清楚。

在我的 header.php 文件中,我有一个简单的 PHP 行(定制的 Wordpress 主题):

<?php if ( is_page('Home') || is_404() ||  is_search() ) { echo ""; } else { echo "<h1>". get_the_title() ."</h1>"; } ?>

在我被要求安装 "The Events Calendar" 插件并使其适应我的主题之前,这一直很好用。

该插件允许我进入其设置并创建一个 URL slug,在这种情况下,我将其命名为 "reunions" 并且我为单个事件创建了 "reunion" slug。所以,从逻辑上讲我应该能够做到这一点:

<?php if ( is_page('Home') || is_page('reunions') || is_page('reunion') || is_404() ||  is_search() ) { echo ""; } else { echo "<h1>". get_the_title() ."</h1>"; } ?>

但这没有用,另外我尝试了这两种方法但没有成功:

$pagenow == 'the-events-calendar.php'

is_plugin_active('the-events-calendar/the-events-calendar.php')

我的解决方法是手动将 <h1>(title)</h1> 添加到每个页面,一定有办法做到这一点。是否可以创建一个 is_plugin('the-events-calendar') 函数来检查插件并禁用 H1 行?

任何帮助将不胜感激:)

您可以使用 is_singular() 函数来检查当前 post 是否属于插件事件自定义 post 类型,如下所示:

<?php if ( is_page('Home') || is_singular('tribe_events')...

更新:

您也可以使用 has_term() 函数来检查特定的 slug,如下所示:

<?php if ( is_page('Home') || has_term('reunions')...