Add only 'Featured Events' category posts to main WordPress loop on home page
-
Hi,
I would like to make events appear on my home page within the main loop.
So far, this function makes all the ‘event’ custom post types show up on the home page
function events_in_home_loop( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( 'post_type', array( 'post', 'event') ); return $query; } add_filter( 'pre_get_posts', 'events_in_home_loop' );
However, I have added an event category called ‘Featured Events’, with the slug ‘featured-events’.
I would like to be able to filter the above query so that only the Events assigned to the ‘Featured Events’ category appear within the loop.
I am unsure of the syntax for filtering a query by an Events Manager category, as well as by ‘post_type’.
Can anyone help out?
Many thanks.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Add only 'Featured Events' category posts to main WordPress loop on home page’ is closed to new replies.