• Resolved John

    (@dsl225)


    Hello,

    I understand I can use [wp_google_searchbox] shortcode to place search box at any page.
    But is it possible to replace the default WP search tool?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WebshopLogic

    (@webshoplogic)

    Hello,

    It is a theme dependent question, different themes have different solutions for replacing search boxes.

    If the theme use a widget for inserting the search box, then you can easily remove the original WordPress search widget and insert the Google Search widget instead.

    Other themes use actions or filters or php templates for customizing the search box. For example in GeneratePress theme I have used ‘generate_inside_navigation’ action to change default WordPress search box to Custom Google searchbox. Inside the action the following PHP statement can be used:

    echo do_shortcode('[wp_google_searchbox]');

    I hope this information was helpful for you.
    Please ask your site designer or the theme developer about the theme dependent possibilities.

    Thread Starter John

    (@dsl225)

    Thanks for this @webshoplogic!

    In this particular case I use Automattic’s Libretto theme that ads the search magnifier at the end of the top menu. As far as I can see, it includes a search.php file with the following content:

    <?php
    /**
     * The template for displaying Search Results pages.
     *
     * @package Libretto
     */
    
    get_header(); ?>
    
    <section id="primary" class="content-area">
    	<div id="content" class="site-content" role="main">
    
    	<?php if ( have_posts() ) : ?>
    
    		<?php /* Start the Loop */ ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    			<?php get_template_part( 'content', 'search' ); ?>
    		<?php endwhile; ?>
    
    		<?php libretto_content_nav( 'nav-below' ); ?>
    
    	<?php else : // If search returns no results ?>
    
    		<?php get_template_part( 'content', 'none' ); ?>
    
    	<?php endif; ?>
    
    	</div><!-- #content -->
    </section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Can I include your statement somewhere there?

    Thanks in advance!

    Plugin Author WebshopLogic

    (@webshoplogic)

    I can see that it is the template of the search result page, but you need the search box. So I suppose it is not the right code.
    I suppose to ask the theme developer, or your site designer how to replace default search box in this particular case.
    You will need some php and css coding skills to do it, if your theme does not support it native way (e.g. not support using a search box widget).

    Thread Starter John

    (@dsl225)

    Yep, you are right!
    No problem then, I’ll check this out.
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Replace default WP search?’ is closed to new replies.