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

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 :)

  • 写回答

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')...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 怎样删除 右键菜单里的 剪切(T)和复制(C)
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题