0

i create a searchform in my footer.php

    <div id="cd-search" class="cd-search">
    <form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
        <input type="search" value="<?php echo get_search_query(); ?>" placeholder="Search...">
        <input type="submit" value="query">
    </form>
</div>

and my search.php like this

<?php

/** * The template for displaying Search Results pages. * * @package Shape * @since Shape 1.0 */

get_header(); ?>

    <section id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

        <?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'shape' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
            </header><!-- .page-header -->

            <?php shape_content_nav( 'nav-above' ); ?>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <?php the_title(); ?>

            <?php endwhile; ?>

        <?php else : ?>

            <?php get_template_part( 'no-results', 'search' ); ?>

        <?php endif; ?>

        </div><!-- #content .site-content -->
    </section><!-- #primary .content-area -->

but when i type something it shows nothing and page just refreshing can anyone help me?

1 Answer 1

0

Try below code in your footer.php :

<div id="cd-search" class="cd-search">
    <form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
        <input type="search" value="<?php echo get_search_query(); ?>" placeholder="Search..." name="s" id="s" >
        <input type="submit" value="query">
    </form>
</div>

You are missing name="s" id="s" which is needed to add in terms of getting search term.

After search you will see that name in your URL parameter something like : yoursite.com/?s=searched

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.