0

I'm using a basis of the Twenty Twelve theme and I'm using the below script (yes I know that the wrappers are not correct as yet).

However it's defaulting back to the main page. Any ideas?

<?php
/**
* The template for displaying Search Results pages.
*
*/ get_header(); ?>

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

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

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

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>
            <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>

    <?php else : ?>

        <article id="post-0" class="post no-results not-found">
            <header class="entry-header">
                <h1 class="entry-title"><?php _e( 'Nothing Found', 'Clearwatch' ); ?></h1>
            </header>

            <div class="entry-content">
                <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'Clearwatch' ); ?></p>
                <?php get_search_form(); ?>
            </div><!-- .entry-content -->
        </article><!-- #post-0 -->

    <?php endif; ?>

    </div><!-- #content -->
</section><!-- #primary -->

Well guys, I double checked my search form and it had index.php in below:

So I changed it to my search.php path and it appears to be searching but defaulting back to my own website theme? Any ideas?

  <form id="searchform" method="get" action="<?php bloginfo('template_url'); ?>/Clearwatch/search.php">
  • Is the file called "search.php"? – Jake Apr 2 '13 at 12:31
  • hi Jake, yes it is – Kirsty Marks Apr 2 '13 at 12:33
1

Ive actually solved this. It appears that there were some errors in the search.php file which resulted in lots of issues.

Thanks for your comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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