Can't get Search form or page to work (1 post)

  1. colleenroxas
    Posted 2 years ago #

    I can't seem to get my search form at the top of my page to work correctly and show results. I've already looked at the wordpress codex guides but I am still lost.

    Here is the url to my site, where I am using a custom theme I created:


    This is the code for my searchform.php:

    <form method="get" id="searchform" class="searchform" action="<?php echo home_url( '/' ); ?>">
    		<input id="s" class="search-box" name="s" size="40" type="text" value="<?php the_search_query(); ?>" placeholder="  SEARCH...  "/>
    		<input id="searchsubmit" class="search-btn" value="&nbsp;" type="submit"/>

    This is the code for my search.php:

    Template Name: Search Page
    global $query_string;
    $query_args = explode("&", $query_string);
    $search_query = array();
    foreach($query_args as $key => $string) {
    	$query_split = explode("=", $string);
    	$search_query[$query_split[0]] = urldecode($query_split[1]);
    } // foreach
    $search = new WP_Query($search_query);
    <?php get_header(); ?>
    		<?php if ( has_post_thumbnail() ) {
    		the_post_thumbnail( 'single-post-thumbnail', array('class' => 'featured-image') );
    		} else { ?>
    		<?php } ?>
    			<div id="content">
    			<?php get_sidebar(); ?>
    			<div id="page-content">
    			<H1>Search Results</H1>
    			<?php get_search_form(); ?>
    			global $wp_query;
    			$total_results = $wp_query->found_posts;
    			</div><!-- end content -->
    <?php get_footer(); ?>

    This is the code in my header.php to display the search box:
    <?php get_search_form( $echo ); ?>

    Finally this is the css I have for the search box:

    		position: relative;
    		font-family: 'Museo Sans';
    		color: #898989;
    		font-size: 11px;
    		font-weight: 500;
    		background: #ebf1e2;
    		padding: 5px 0 5px 5px;
    		border: 0 none;
    		width: 160px;
    	 .searchform {
    		 display: inline;
    	 .search-btn {
    	 	margin-left: -5px;
    	 	background: url('images/icon-search.png') center no-repeat #ebf1e2;
    		font-family: 'Museo Sans';
    		color: #fff;
    		font-size: 11px;
    		font-weight: 500;
    		padding: 5px 15px;
    		border: 0 none;

Topic Closed

This topic has been closed to new replies.

About this Topic