WordPress.org

Ready to get started?Download WordPress

Forums

Searching kicks me to the blog page (11 posts)

  1. Centigrade
    Member
    Posted 2 years ago #

    Hey,

    Just needing some help regarding setting up the search function. I'm building off of the Clean Home theme (because it was pretty bare bones). It doesn't come with a default searchform so I tried adding one. No matter how I set it up it either displays a blank page (with correct header and footer) or it simply kicks me out to the default blog page.

    Even if i list tags, which are clickable, they also kick me to the blog page.

    Any ideas?

    Cheers.

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    What's in your searchform.php file?

  3. Centigrade
    Member
    Posted 2 years ago #

    Sorry here's the code, it pretty standard stuff. I'll redo the results page once it starts listing the correct things.

    searchform.php:

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    	<label class="hidden" for="s"><?php _e('Search:'); ?></label>
    	<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    	<input type="submit" id="searchsubmit" value="GO" />
    </form>

    And the search results page just taken from the twentyten theme:

    <?php
    /**
     * The template for displaying Search Results pages.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    
    get_header(); ?>
    
    		<div id="container">
    			<div id="content" role="main">
    
    <?php if ( have_posts() ) : ?>
    				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'cleanhome' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    				<?php
    				/* Run the loop for the search to output the results.
    				 * If you want to overload this in a child theme then include a file
    				 * called loop-search.php and that will be used instead.
    				 */
    				 get_template_part( 'loop', 'search' );
    				?>
    <?php else : ?>
    				<div id="post-0" class="post no-results not-found">
    					<h2 class="entry-title"><?php _e( 'Nothing Found', 'cleanhome' ); ?></h2>
    					<div class="entry-content">
    						<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'cleanhome' ); ?></p>
    						<?php get_search_form(); ?>
    					</div><!-- .entry-content -->
    				</div><!-- #post-0 -->
    <?php endif; ?>
    			</div><!-- #content -->
    		</div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  4. esmi
    Forum Moderator
    Posted 2 years ago #

    searchform.php looks OK - although you should really be using <?php echo esc_url( home_url( '/' ) ); ?> rather than <?php bloginfo('url'); ?>/. what happens if you remove the file?

  5. Centigrade
    Member
    Posted 2 years ago #

    Hey I'll just give you the staging url...

    whatkateate(dot)centigrade(dot)ca

    replace the dots... just don't want search engines picking it up.

    So right now the search form in the sidebar either gives you a blank page or brings you to the blog page. Still under construction so lots of links are pretty bare.

    If i take out the searchform.php then it always brings me to the blog.

  6. Centigrade
    Member
    Posted 2 years ago #

    Oh crap... url is wrong:

    whatkatieate(dot)centigrade(dot)ca

  7. esmi
    Forum Moderator
    Posted 2 years ago #

    If i take out the searchform.php then it always brings me to the blog.

    And you are definitely searching for text that you know is there? I usually test using a common word such as "and" if I have "real" post content to play with.

  8. Centigrade
    Member
    Posted 2 years ago #

    Yep. If you do a search from th homepage right now for and it'll display the search results page... with Nothing found message.

    If however I search for Lemon... which is an ingredient and in many of the posts and titles... then I get a different page... but it's not displaying the actual posts. So I guess it's half working.

    Thanks for all the help so far BTW!

  9. Centigrade
    Member
    Posted 2 years ago #

    hmmm. I just changed the theme to a really barebones theme, and search is working now. Must be an issue with the clean home theme.

  10. esmi
    Forum Moderator
    Posted 2 years ago #

  11. Centigrade
    Member
    Posted 2 years ago #

    That's great thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic