Trying to accomplish the following. Any help / advice is greatly appreciated. 1) I have multiple site on subdirectory using wp multisite names (e.g., /, /, /). 2) I need post each domain to display the same content & images (featured image) BUT 3) Show a different Wordpress Theme, Plugins & Plugin Configuration. etc
Trying to accomplish the following. Any help / advice is greatly appreciated. 1) I have multiple site on subdirectory using wp multisite names (e.g., https://noorshaad/uae/, https://noorshaad/us/, https://noorshaad/uk/). 2) I need post each domain to display the same content & images (featured image) BUT 3) Show a different Wordpress Theme, Plugins & Plugin Configuration. etc
Share Improve this question asked Oct 12, 2019 at 17:47 Shaad AminShaad Amin 131 silver badge5 bronze badges1 Answer
Reset to default 0Here's a concept code (i.e. not tested, requires tweaking) that you could maybe use. With this example a post you create would get cloned to other subsites in your network.
function copy_content( $post_id, $post, $update ) {
// check for revision, autosave, etc.
$args = array(
'site__not_in' => array( get_current_blog_id() ),
);
$sites = get_sites( $args );
$post = $post->to_array(); // post object to array as insert/update functions require array
foreach ($sites as $site) {
switch_to_blog( $site->blog_id );
if ( $update ) {
wp_update_post( $post );
} else {
wp_insert_post( $post );
}
restore_current_blog();
}
}
add_action( 'save_post', 'copy_content', 10, 3 );
Another option could be to use pre_get_posts
on your subsites to pull posts from one main posts site. This has been covered for example here, How would I use pre_get_posts to query another site for posts in my multisite network?