Skip Navigation

[Resolved] Loading a view from one site on another in WordPress Multisite

This thread is resolved. Here is a description of the problem and solution.

Problem:

Will Toolset View (version3) plugin would support loading a view from one site on another in WordPress Multisite?

Solution:

There isn't such kind of built-in feature within Toolset plugins, it needs custom codes, for example, you can try these:

https://toolset.com/forums/topic/loading-a-view-from-one-site-on-another-in-wordpress-multisite/#post-1363179

Relevant Documentation:

https://developer.wordpress.org/reference/functions/switch_to_blog/

https://codex.wordpress.org/Function_Reference/add_shortcode

This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by koheiY 5 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1363095

Will Toolset View (version3) plugin would support loading a view from one site on another in WordPress Multisite?

I read these threads, but I want to confirm.
https://toolset.com/forums/topic/how-to-take-view-shortcode-from-one-site-to-another-site-in-wordpress-multisite/
https://toolset.com/forums/topic/views-from-another-site-of-multisite/

What I want to do and my situation:

I have a WP multisite and run some sites in the network.
Subsite3 (blog_id = 3) has a view named "item list".
I can display the view by insert shortcode "[wpv-view name="item-list"]" in the Subsite3.
I have Subsite4 (blog_id = 4) and I want to display the same item list as the Subsite 3.
If can, I want to insert view shortcode like "[wpv-view name="item-list" blog_id="3"] in the Subsite 4.

#1363179

Hello,

There isn't such kind of built-in feature within Toolset plugins, it needs custom codes, for example, you can try these:
1) Activate Toolset Views plugin in both subsites: Subsite3 and Subsite 4

2) Create a custom shortcodes in Subsite 4:

add_shortcode('switch_to_blog', function($atts, $content){
	$atts = shortcode_atts( array(
		'bid' => '',
	), $atts);
	$res = '';
	if($atts['bid']){
		switch_to_blog($atts['bid']);
		$res = do_shortcode($content);
		restore_current_blog();
	}
	return $res;
});

3) In Subsite 4, use above custom shortcode, like this:

[switch_to_blog bid="3"]
Here display target subsite3 contents:
[wpv-view name="item-list"]
[/switch_to_blog]

Please replace number 3 with your Subsite3 blog's ID.

More help:
https://developer.wordpress.org/reference/functions/switch_to_blog/
https://codex.wordpress.org/Function_Reference/add_shortcode

#1363315

My issue is resolved now. Thank you!