Support

Home Forums Event Espresso Premium Event Posts appearing in default WP Posts

Event Posts appearing in default WP Posts

Posted: August 18, 2016 at 4:30 pm

Viewing 2 reply threads


yamamDev

August 18, 2016 at 4:30 pm

All my event posts are showing up in the default wp_posts of my site. Its happening in both the admin section and in wp_queries of the default posts.

when I try to delete or edit the events that are in the default posts section of the admin, it does one of 3 things:

1) Nothing and the page refreshes.
2) Sends me to the landing page of the WP Dashboard
3) Gives me an alert that says, “Invalid Post Type”

Please advise on how I can resolve this issue as it is going to be very confusing for my end client.

Thank you


Lorenzo Orlando Caum

  • Support Staff

August 19, 2016 at 7:29 am

Hello,

Events in Event Espresso uses a custom post type of espresso_events so you should not be seeing events appearing in the Posts overview screen in your WP dashboard.

Do you have a plugin in use that pulls in custom post types to that screen?


Lorenzo


yamamDev

August 19, 2016 at 7:57 am

I ended up realizing the issue. I took a snippet off EE code snippets page that I initally misread as creating events as their own custom post type. Where it was actually putting the events post type in the default posts.

Sorry for the confusion, and thanks for the help!

Add events to any blog archive listing and rss feed

function add_espresso_events_to_posts( $WP_Query ) {
  if ( $WP_Query instanceof WP_Query && ( $WP_Query->is_feed || $WP_Query->is_posts_page  || ( $WP_Query->is_home && ! $WP_Query->is_page ) ||  ( isset( $WP_Query->query_vars['post_type'] ) && ( $WP_Query->query_vars['post_type'] == 'post' || is_array( $WP_Query->query_vars['post_type'] ) && in_array( 'post', $WP_Query->query_vars['post_type'] ) ) ) ) ) {
    //if post_types ARE present and 'post' is not in that array, then get out!
    if ( isset( $WP_Query->query_vars['post_type'] ) && $post_types = (array) $WP_Query->query_vars['post_type'] ) {
      if ( ! in_array( 'post', $post_types ) ) {
        return;
      }
    } else {
      $post_types = array( 'post' );
    }
    if ( ! in_array( 'espresso_events', $post_types )) {
      $post_types[] = 'espresso_events';
      $WP_Query->set( 'post_type', $post_types );
    }
    return;
  }
}
add_action( 'pre_get_posts', 'add_espresso_events_to_posts', 10 );
Viewing 2 reply threads

The support post ‘Event Posts appearing in default WP Posts’ 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