• Resolved Steve D

    (@steadwell)


    First of all, I love the theme!

    However, attempting to customize the search.php module (in a child theme), to add multisite search functionality, I can’t locate “the loop”, since this theme is structured differently from other theme templates I’ve seen in the past.

    Has anyone run into this with optimizer? Any pointers would be greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author OptimizerWP

    (@layerthemes)

    Steve,

    Can you please elaborate what you are trying to achieve?

    The theme already contains the search.php file. try copying to your child theme and start modifying it. ??

    Regards

    Thread Starter Steve D

    (@steadwell)

    I’m using the Optimizer theme for my main site “landing page” of a network install, with navigation to all the sub-sites from it. One of the features I need, is a network wide search for all sub-sites.

    I have a plugin called “wp-search-mu”, which resides in the “mu-plugins” folder in wp-content, it’s a “must use” plugin, as opposed to “inactive”, “active”, etc… It is for adding global, network wide capability to your search. In the search.php, I would normally insert 2 lines of code, 1 after the while instruction, and the other before the endwhile instruction, as such:

    <?php if ( have_posts() ) : // Checks if any posts were found. ?>
    
    		<?php while ( have_posts() ) : // Begins the loop through found posts. ?>
    
    			<?php switch_to_blog($post->blog_id); ?>
    
    			<?php the_post(); // Loads the post data. ?>
    
    			<?php hybrid_get_content_template(); // Loads the content/*.php template. ?>
    
    			<?php restore_current_blog(); ?>
    
    		<?php endwhile; // End found posts loop. ?>

    Optimizer wp-search.php is using “template_part”, and I cannot find the module that contains “the loop” for processing search records. I could change-up the wp-search.php module, but would rather keep it in line with the structure of the theme. I hope I am explaining my question adequately.

    Thanks for the prompt response!

    Theme Author OptimizerWP

    (@layerthemes)

    Steve,

    You can create a child theme and add the below code to your theme’s functions.php
    or You can install this plugin:
    https://www.ads-software.com/plugins/my-custom-functions/

    and then Go to Appearance> Custom Functions and add this:

    add_action( 'loop_start', 'wpse107113_loop_start' );
    function wpse107113_loop_start( $query ){
         if( $query->is_search() ){
    switch_to_blog($post->blog_id);
         }
    }
    add_action( 'loop_end', 'wpse107113_loop_end' );
    function wpse107113_loop_end( $query ){
         if( $query->is_search() ){
    restore_current_blog();
         }
    }

    Let me know.

    Thread Starter Steve D

    (@steadwell)

    I believe I’ve resolved the issue by copying the “template_parts” folder into my child theme folder, and copying the 2 post format templates into it. I then renamed them to search… instead of post…, and changed the search.php in my child folder to call template_parts with “search” instead of “post”. It appears to be working, however, I like your functions approach as well, it’s probably cleaner.

    I will tinker around with your idea in addition to what I’ve done, but I’ll go ahead and mark this as resolved.

    Thanks for looking into it, you’ve been a great help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Implementing WP Search MU’ is closed to new replies.