• Resolved naminta

    (@naminta)


    Hey all,

    the following problem:

    I need a networkwide search engine, tried some plugins, don’t work the way they should, now i found a nice article: search-across-wp-multisite

    And I want to change the search.php as mentioned, but my problem was step 3, the replacements, because most of them are not given -.-‘

    Do I have to change the whole search.php to make it work?

    Here is my search.php, working with the AVADA Theme

    <?php
    
    // Do not allow directly accessing this file.
    if ( ! defined( 'ABSPATH' ) ) {
    	exit( 'Direct script access denied.' );
    }
    ?>
    <?php get_header(); ?>
    <div id="content" <?php Avada()->layout->add_class( 'content_class' ); ?> <?php Avada()->layout->add_style( 'content_style' ); ?>>
    	<?php if ( have_posts() && 0 != strlen( trim( get_search_query() ) ) ) : ?>
    
    		<?php if ( 'bottom' == Avada()->settings->get( 'search_new_search_position' ) ) : ?>
    			<?php get_template_part( 'templates/blog', 'layout' ); ?>
    			<div class="fusion-clearfix"></div>
    		<?php endif; ?>
    
    		<?php if ( 'hidden' != Avada()->settings->get( 'search_new_search_position' ) ) : ?>
    			<div class="search-page-search-form search-page-search-form-<?php echo Avada()->settings->get( 'search_new_search_position' ); ?>">
    				<?php
    				/**
    				 * Render the post title
    				 */
    				echo avada_render_post_title( 0, false, esc_html__( 'Need a new search?', 'Avada' ) );
    				?>
    				<p><?php esc_html_e( 'If you didn\'t find what you were looking for, try a new search!', 'Avada' ); ?></p>
    				<form class="searchform seach-form" role="search" method="get" action="<?php echo home_url( '/' ); ?>">
    					<div class="search-table">
    						<div class="search-field">
    							<label class="screen-reader-text" for="searchform"><?php _e( 'Search for:', 'Avada' ); ?></label>
    							<input id="searchform" type="text" value="" name="s" class="s" placeholder="<?php esc_html_e( 'Search ...', 'Avada' ); ?>"/>
    						</div>
    						<div class="search-button">
    							<input type="submit" class="searchsubmit" value="" />
    						</div>
    					</div>
    				</form>
    			</div>
    		<?php endif; ?>
    
    		<?php if ( 'top' == Avada()->settings->get( 'search_new_search_position' ) || 'hidden' == Avada()->settings->get( 'search_new_search_position' ) ) : ?>
    			<?php get_template_part( 'templates/blog', 'layout' ); ?>
    		<?php endif; ?>
    
    	<?php else : ?>
    
    		<div class="post-content">
    
    			<?php echo Avada()->template->title_template( esc_html__( 'Couldn\'t find what you\'re looking for!', 'Avada' ) ); ?>
    			<div class="error-page">
    				<div class="fusion-columns fusion-columns-3">
    					<div class="fusion-column col-lg-4 col-md-4 col-sm-4">
    						<h1 class="oops"><?php esc_html_e( 'Oops!', 'Avada' ); ?></h1>
    					</div>
    					<div class="fusion-column col-lg-4 col-md-4 col-sm-4 useful-links">
    						<h3><?php esc_html_e( 'Helpful Links:', 'Avada' ); ?></h3>
    						<?php $circle_class = ( Avada()->settings->get( 'checklist_circle' ) ) ? 'circle-yes' : 'circle-no'; ?>
    						<?php wp_nav_menu( array(
    							'theme_location' => '404_pages',
    							'depth'          => 1,
    							'container'      => false,
    							'menu_class'     => 'error-menu list-icon list-icon-arrow ' . $circle_class,
    							'echo'           => 1,
    						) ); ?>
    					</div>
    					<div class="fusion-column col-lg-4 col-md-4 col-sm-4">
    						<h3><?php esc_html_e( 'Try again', 'Avada' ); ?></h3>
    						<p><?php esc_html_e( 'If you want to rephrase your query, here is your chance:', 'Avada' ); ?></p>
    						<?php echo get_search_form( false ); ?>
    					</div>
    				</div>
    			</div>
    		</div>
    	<?php endif; ?>
    </div>
    <?php do_action( 'avada_after_content' ); ?>
    <?php get_footer();
    
    /* Omit closing PHP tag to avoid "Headers already sent" issues. */
    

    Hope someone can help

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The code you posted does not appear to contain the loop that outputs search results, so despite the same name, you’re in the wrong place. One of the templates loaded through get_template_part() probably contains the loop. That is the code you need to alter per the article.

    Since you are using a commercial theme, there is little we can do to help you with specifics. Among several reasons is we do not have access to the source code. Posting their code here is likely violating terms of their copyright.

    Thus I can only speak in the most general terms. Once you locate the output loop, it’s not going to look exactly like the article’s examples. You need to do some interpretation to identify code that does the same thing even if it appears differently.

    For more specific help, use your theme’s official support channel. If they are not forth coming, you could hire an expert to work this out at jobs.wordpress.net.

    Thread Starter naminta

    (@naminta)

    Thanks for pointing that out with the source code. Your were right, there is a location where the loop can be found and edit. Thank you very much (again ?? )

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘change the search.php’ is closed to new replies.