Forums › Forums › Search & Filter Pro › Using plugin on multisite with custom post
Tagged: multisite
- This topic has 7 replies, 3 voices, and was last updated 4 years, 9 months ago by Ross.
-
Anonymous(Private) March 18, 2020 at 4:51 am #237004
I have a multisite website (10 sites) that have a custom post type called members…. on the main website. I want to display the members from the other websites. here is how I set it up
– http://www.mainsite.com/subsite-1/subsite-2-list/
– http://www.mainsite.com/subsite-2/On subsite 1, I need to display the custom post type MEMBERS on subsite 2, I created a form on subsite 2 and chose the shortcode display method, I indicated that the results should display in http://www.mainsite.com/subsite-1/subsite-2-list/
[searchandfilter id="2"] [searchandfilter id="2" show="results"]
then on functions.php of subsite-1, I created a function that calls the shortcode created/from subsite-2 like this
// Add Shortcode function view_mems() { switch_to_blog( 2 ); $output = do_shortcode('[searchandfilter id="2"]'); restore_current_blog(); return $output; } add_shortcode( 'viewme', 'view_mems' ); // Add Shortcode function list_mems() { switch_to_blog( 2 ); $output = do_shortcode('[searchandfilter id="2" show="results"]'); restore_current_blog(); return $output; } add_shortcode( 'listme', 'list_mems' );
On http://www.mainsite.com/subsite-1/subsite-2-list/, I then used the shortcodes/function above to display the forms from subsite-2, this works all fine, pagination works and displays the posts BUT the search form doesn’t work with or without ajax enabled, if you click submit, it just reloads the page and doesn’t do a search.
Trevor(Private) March 18, 2020 at 8:00 am #237018Our search creates cache tables for each site on the multisite, and within each site, does not look at the cache tables in another site, hence the search itself would not work.
I will ask our developer, Ross, if there is any way to achieve what you want.
Anonymous(Private) March 18, 2020 at 8:42 am #237022Manually adding the search parameters like http://www.mainsite.com/subsite-1/subsite-2-list/?_sf_s=SEARCHTERM&sort_order=title+asc works perfectly too.
Ross Moderator(Private) March 18, 2020 at 8:50 am #237026Hi Shaan
While we don’t support searching across multisites, I would have thought what you are trying to do might be possible (with
switch_to_blog
) at least to access another sites particular set of results.What I will say is, the search form is entirely submitted by Javascript, so I’m thinking, maybe on your subsite, you don’t have the S&F javascript loaded in the page head?
Thanks
Ross Moderator(Private) March 18, 2020 at 8:52 am #237028Also, in your main site Search Form, did you set the “results URL” to the results URL of your sub site?
Anonymous(Private) March 18, 2020 at 9:05 am #237031The main site also has a page that lists its own members, so there are 2 forms/pages on the main site:
http://www.mainsite.com/subsite-1/subsite-1-list/ and http://www.mainsite.com/subsite-1/subsite-2-list/, both have unique search forms.
http://www.mainsite.com/subsite-1/subsite-1-list/ works as it should. The search form for this page is set to display the results to http://www.mainsite.com/subsite-1/subsite-1-list/
While the other search form, the form from the other website inside the multisite is set to display on http://www.mainsite.com/subsite-1/subsite-2-list/, all JS are in wp_head
Anonymous(Private) March 18, 2020 at 4:50 pm #237101Checked again…. found that http://www.mainsite.com/subsite-1/subsite-2-list/ did not have the S&F js.
I added them manually and now everything works!!! -
AuthorPosts