简体   繁体   中英

Wordpress - if is_plugin function?

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

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')...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM