Reply To: Videos not showing up on homepage

#270

Constantin
Keymaster

If you don’t want to make your theme compatible with the plugin, you could try to alter the query on your homepage to display the videos. To do this, try to add the following code into your WordPress theme functions.php file:

/**
 * Add videos to homepage
 */
function ccb_youtube_videos_homepage( $query ) {
	// check that page isn't admin page, is homepage and the query
	if ( !is_admin() && is_home() && $query->is_main_query() ){
		// add video post type to query
		$query->set( 'post_type', array( 'post', 'video' ) );
	}
	return $query;	
}
add_filter( 'pre_get_posts', 'ccb_youtube_videos_homepage' );