Support

Home Forums Event Espresso Premium Conditional Loading of Javascript

Conditional Loading of Javascript

Posted: June 20, 2015 at 9:23 am

Viewing 2 reply threads


Joshua Parker

June 20, 2015 at 9:23 am

I am trying to use a conditional code which will only load event espresso js script(s) if the current post matches the custom post type. The reason I am wanting to do this is because it is conflicting with my shopping cart. I’ve tried the following code below by putting it into a functions file under my child theme, but it is not working:

if(is_singular('espresso_events') === false) {
	add_filter( 'FHEE_load_js', '__return_false' );
}

It’s not working because it is removing the js file from every page including the event espresso pages. Is there another way to achieve this?


Josh

  • Support Staff

June 20, 2015 at 10:14 am

There are plenty, here’s one you can try:

$post = get_post( $post_id );
if ( ! $post || 'espresso_events' != $post->post_type ) {


Joshua Parker

June 20, 2015 at 11:30 am

Brilliant, thank you.

Viewing 2 reply threads

The support post ‘Conditional Loading of Javascript’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso