aharon 0 Report post Posted March 8, 2011 Ok, I have a need for search across my multisite Wordpress install. In the instructions for the wpSearchMu plugin it says to apply the following code to my search.php file at the beginning of the loop: 1 switch_to_blog($post->blog_id); And to add this: restore_current_blog(); At the end of the loop. Should be simple. Except I am assuming that search.php is dynamically made or some other ninja move like that. So the question is, to make this work where would I need to put that code snippet. Thanks! Share this post Link to post Share on other sites
cmunns 16 Report post Posted March 8, 2011 look at the bottom of the template.postloop.php file, its down there. Share this post Link to post Share on other sites
aharon 0 Report post Posted March 8, 2011 Yeah I saw that, but I need to put that code snippet in the loop of the search. I don't see a loop for search in there... at least it doesn't look like the suggestion on: http://welcome.totheinter.net/wpsearchmu/ I'll be honest, my PHP is really green, but it looks like to me that the section in the bottom is handling for zero search results... right? Share this post Link to post Share on other sites
bryan-hadaway 3 Report post Posted March 9, 2011 Marking for further developer help. Thanks, Bryan Share this post Link to post Share on other sites
aharon 0 Report post Posted March 9, 2011 Thanks Bryan, This is a hugely needed feature for our rollout. Hopefully you ninjas can figure this out. What happens is that I can search and see the post summaries in the results so that's good. But it doesn't throw up the right URL, which according to the plugin's site is because of that code not being in the loop thing. Share this post Link to post Share on other sites
cmunns 16 Report post Posted March 9, 2011 Well you are correct, but the template.postloop.php is what controls all the loops even cat, tag, search...if you want to change the way it displays you would have to add a conditional tag and modify it that way. So just wrap the code they tell you to inject by doing this: ` if is_search(): your code here endif; ` and that would go at the beginning and end of loop as the plugin suggests. Share this post Link to post Share on other sites
aharon 0 Report post Posted March 11, 2011 Did that: // Start of 'The Loop' if(is_search(): switch_to_blog($post->blog_id); endif; Then I got this error: Parse error: syntax error, unexpected ';' in /var/www/public_html/2011.empowermm.com/wp-content/themes/platformpro/template.postloop.php on line 28 Any other ideas? Thanks again for your help with this. I'm sure I'm not the only one who would like this to work. Share this post Link to post Share on other sites
aharon 0 Report post Posted March 11, 2011 Figured out! It was in the wrong spot... here's how it should look: // Start of 'The Loop' if(have_posts()){ while (have_posts()) : the_post(); if(is_search()) { switch_to_blog($post->blog_id); } Woot. Thanks for the tip. Share this post Link to post Share on other sites