douchu5131
2017-07-24 17:07
浏览 49
已采纳

Wordpress - 如果is_plugin功能?

So, I have been trying a couple of things but I can't figure it out.

In my header.php file I have a simple PHP line (custom-made Wordpress theme):

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

This was working GREAT until I was required to install "The Events Calendar" plugin and adapt it to my theme.

The plugin allows me to go into its settings and create a URL slug, in this case I named it "reunions" and I did "reunion" slug for single events. So, logically I should be able to do this:

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

But this didn't work, additionally I tried these two things but no luck:

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

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

My work around would be to manually add <h1>(title)</h1> to each page, there's gotta be a way to do this. Is it possible to create a is_plugin('the-events-calendar') function to check for the plugin and disable the H1 line?

Any help would be greatly appreciated :)

图片转代码服务由CSDN问答提供 功能建议

所以,我一直在尝试一些事情,但我无法弄明白。 \ n

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

 &lt;?php if(is_page('Home  ')|| is_404()|| is_search()){echo“”;  } else {echo“&lt; h1&gt;”。  get_the_title()。“&lt; / h1&gt;”;  }?&gt; 
   
 
 

在我需要安装“The Events Calendar”插件并使其适应我的主题之前,这个工作很棒。

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

 &lt;?php if(is_page('Home')|| is_page('reunions')|| is_page('  reunion')|| is_404()|| is_search()){echo“”;  } else {echo“&lt; h1&gt;”。  get_the_title()。“&lt; / h1&gt;”;  }?&gt; 
   
 
 

但这不起作用,另外我尝试了这两件事,但没有运气:

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

is_plugin_active('the-events-calendar / the-events-calendar.php') < p>我的工作是手动将&lt; h1&gt;(标题)&lt; / h1&gt; 添加到每个页面,必须有一种方法可以做到这一点。 是否可以创建一个is_plugin('the-events-calendar')函数来检查插件并禁用H1行?

任何帮助将不胜感激:)

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongsui0929 2017-07-24 17:36
    已采纳

    You could use is_singular() function to check if the current post is of plugin's event custom post type, like this:

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

    Update:

    You could also use has_term() function, to check for specific slug, like this:

    <?php if ( is_page('Home') || has_term('reunions')...
    
    打赏 评论

相关推荐 更多相似问题