Support

Home Forums Event Espresso Premium How do I include Events in my Blog?

How do I include Events in my Blog?

Posted: May 23, 2014 at 4:39 pm


sakirose

May 23, 2014 at 4:39 pm

How would I include the events in my regular wordpress blog (along with regular blogs)?


Josh

  • Support Staff

May 23, 2014 at 7:08 pm

Hi Sakirose,

This can be done by adding a little function to a custom code snippets plugin or your theme’s functions.php file:

function my_add_espresso_events_to_blog( $WP_Query ) {	
	if (( $WP_Query->is_posts_page || is_archive() || is_category() || is_tag() || is_tax() || is_date() || is_day() || is_month() || is_robots() || is_search() || is_year() )&& empty( $WP_Query->query_vars['suppress_filters'] )) {
		$post_types = isset( $WP_Query->query_vars['post_type'] ) ? (array)$WP_Query->query_vars['post_type'] : array( 'post' );
		$post_types[] = 'espresso_events';
		$WP_Query->set( 'post_type', $post_types );
		return $WP_Query;
	}
}
add_action( 'pre_get_posts', 'my_add_espresso_events_to_blog', 10, 1 );

The support post ‘How do I include Events in my Blog?’ 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