Podcast Network like setup with Multisite

Hey there,

I'm just starting a new wordpress build for a podcast site. This is something like a small network - it's actually a Podcast with 3 different shows (maybe more in the future). Unfortunately there's no WordPress Podcast solution out there that is great and supports multiple shows with totally different Title, Description, Artwork, Feed settings etc. - at least none that i like. I basically do like Podlove Publisher but to setup different feed you need to have a multisite installation and basically have different blogs.

So I'll be going with a subdirectory setup with 4 blogs at all - one "main" blog with all the central information and 3 show blogs with one for each show that will most likely only hold the episode pages, an overview of episodes and maybe one static site.

Additionally i'm probably going to use WP-Types/Toolset to build some views and modify the output in an easy way.

The thing is i want to have the lastest episodes from each of the shows in the main blog - at least on the home page. Unfortunately Toolset Views doesn't seem to be able to query other blogs than the one it is running on - so no support for switch_to_blog or anything else.

Now I found out that the post indexer plugin could be a good base but i couldn't find any information yet if there's something like an interface to wp_query or similar that would allow other plugins that work with custom post types to easily query the indexed posts.

Does anyone have an idea where I could find such information or how this "problem" could be approached? Apart from Toolset... what would normally be the way to query indexed posts from the theme?

Thanks!
Frank

  • Luís

    Hi Helmi ,

    Hope you're doing well today!

    Firstly, sorry for my late reply and all the problems it may have caused.

    Right, Recent Global Post shows the last posts from all blogs in the network, the number can be defined.

    However, to achieve it you will need to add some custom code. I flagged the SLS team (our code experts :slight_smile: ) to investigate further and get their valuable feedback.

    Since this team deals with more advanced threads it may take them longer to reply.

    Cheers, Luís

  • Panos

    Hi Helmi ,

    Not sure how WP-Types/Toolset Views work, but I guess they create a new custom post type with some meta values.

    There are two options to get posts (or podcasts post type) from the network:

    1. Using switch_to_blog:

    $podcasts_list = array();
    
    $blogs = wp_get_sites( $args );
    
    foreach( $blogs as $blog ) {
    
    	switch_to_blog( $blog['blog_id'] );
    
    		$args = array(
    			'post_type' 		=> 'podcast',
    			'posts_per_page' 	=> 5//OR  -1 for all
    		);
    
    		$podcasts = new WP_Query( $args );
    
    		if( $podcasts->have_posts() ) {
    			while( $podcasts->have_posts() ) {
    				$podcasts->the_post();
    
    					global $post;
    
    					$podcasts_list[] = $post;
    			}
    		}
    
    		wp_reset_postdata();
    
    	restore_current_blog();
    }
    
    print_r( $podcasts_list );

    2. Using our Post Indexer plugin. It should index podcast CPT and get latest posts periodically. The Post Indexer stores posts content from all network in one table so you need to only query that table. It does use a postmeta table but it doesn't store that much in that table.

    In case you only need the content of the podcast and not meta values I would say go for the Post Indexer, as it would require less queries.

    Regarding the Post Indexer method you could try out something like the following:

    function wpmudev_list_network_podcasts( $limit ){
    
    	global $wpdb;
    
    	$podcasts = array();
    
    	$limit_str = is_numeric( $limit ) ? 'LIMIT ' . $limit : '';
    
    	$net_query = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}network_posts WHERE post_type='podcast' {$limit_str}" );
    
    	if( !empty( $net_query ) ){
    
    		foreach ($net_query as $podcast ) {
    
    			$podcasts[] = $podcast;
    
    		}
    
    	}
    
    	return $podcasts;
    
    }
    
    $glob_podcasts = wpmudev_list_network_podcasts( 5 );

    Hope this helps! Please let me know if you need further information :slight_smile:

    Thanks!
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.