a
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudanti.
a
Follow Me
Search
How to Update my theme search template if products link are incorrect - WooCommerce MultiSite Global Cart
14835
post-template-default,single,single-post,postid-14835,single-format-standard,cookies-not-set,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-5.0.1,vc_responsive
 

How to Update my theme search template if products link are incorrect

WooCommerce MultiSite Global Cart / Articles  / How to Update my theme search template if products link are incorrect
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

How to Update my theme search template if products link are incorrect

When doing a WordPress WooCommerce MultiSite Search, the results are returned often within WooCommerce template called archive-product.php This is managed automatically through the internal code to return appropriate product link, depending on the shop in the network where is being located.
Some of WordPress Themes use own search template which is mostly found within search.php file available within the theme directory. So the default WordPress editor or a specialized tool can be used to edit that file as follow:

Locate the following code in the template file:

 			while ( have_posts() ) :
				the_post();

				get_template_part( 'template-parts/content/content', 'excerpt' );
                
			endwhile;

This need a bit of update to include the switch_to_blog() and restore_current_blog() so add the 2 new lines:

			while ( have_posts() ) :
				the_post();
                
                if  ( isset($post->blog_id) ) { switch_to_blog ($post->blog_id); }

				get_template_part( 'template-parts/content/content', 'excerpt' );
                
                if  ( isset($post->blog_id) ) { restore_current_blog(); }

			endwhile;

At this point the products within the search interface include the correct links.