Support

Home Forums Event Espresso Premium is_post_type_archive('espresso_events') not working

is_post_type_archive('espresso_events') not working

Posted: May 12, 2017 at 8:52 am

Viewing 2 reply threads


Jerry

May 12, 2017 at 8:52 am

I’m using the following code in functions.php to suppress share buttons on the Event Espresso pages (and on another custom post type, Staff).

add_filter(‘addthis_post_exclude’, ‘addthis_post_exclude’);
function addthis_post_exclude($display) {
if (
( is_singular(‘espresso_events’) ) ||
( is_post_type_archive(‘espresso_events’) ) ||
( is_post_type_archive(‘staff’) )
)
$display = false;
return $display;
}

This is working for the Staff archive pages and for the Event single pages, but NOT for the Event archive pages.

Any suggestions? Thanks!


Josh

  • Support Staff

May 12, 2017 at 9:32 am

The code as is works for me, but there are some potential gotchas that can happen with the way it’s formatted. Can you try this instead?

add_filter( 'addthis_post_exclude', 'my_addthis_post_exclude' );
function my_addthis_post_exclude( $display ) {
  if ( 
    is_singular( 'espresso_events' )  ||
    is_post_type_archive( array( 'espresso_events', 'staff' ) ) 
  ) { 
    $display = false;
  }
  return $display;
}


Jerry

May 12, 2017 at 9:41 am

Works! Thanks!!

Viewing 2 reply threads

The support post ‘is_post_type_archive('espresso_events') not working’ 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