WordPress search with quotations returning to homepage
-
Hey all,
I’m currently trying to debug a problem with a site. When I use our search, it works perfectly fine, unless I try to search with single or double quotation marks.
For example, if I search facebook, it works fine, but if I search “facebook” it returns me to my homepage.
The site can be viewed at: https://ccdev.gnof.org/
The code for searchform.php:
<div id="searchOverlay" style="display:none;background:rgba(250,250,250,.9);z-index:999999;position:fixed;top:0;left:0;right:0;bottom:0;"> <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <div id="closeSearch" style="position:absolute;top:110px;right:50%;margin-right:-460px;font-family: 'Open Sans Condensed', sans-serif;text-transform:uppercase;cursor:pointer;color:#333;"><span style="color:#f66;font-family:helvetica, sans-serif;">X</span> Close</div> <input type="text" id="searchInput" placeholder="Search GNOF" onclick="value=''" style="width:910px;border:0 none;left:50%; margin-left:-475px;top:20px;position:absolute;box-shadow:none;font-family: 'Open Sans Condensed', sans-serif;font-weight:bold;font-size:40px;margin-top:115px;padding:0 20px;height:100px;background:none;" autofocus="true" name="s"/> <input type="image" src="https://civiccenter.cc/images/search.png" width="12" height="12" id="searchsubmit" value="Search" border="0" /> </form> <p style="color:#000; width:910px; margin:185px auto;">Begin typing to search, then press enter.</p> </div>
and the code for search.php:
<?php /* */ ?> <?php get_header(); ?> <!-- News Feed Begins --> <div class="container section page"> <!-- the additional page class tell us that this div needs a margin on top too --> <div class="row"> <div class="span8 news-feed"> <div class="feed-title"> <p><small><i>Search Results for <?php echo get_search_query(); ?></i></small></p> <hr> </div> <?php while ( have_posts() ) : the_post(); ?><br> <div class="feed-item"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><small><i>Posted to <?php //the_time('F j'); ?> <?php //the_category(); ?> <?php $categories = get_the_category(); $separator = ', '; $output = ''; $i = 0; $catArr = array(); $exclude = array('Newsroom', 'Our Community', 'Announcement - Urgent', 'Announcement', 'Grants', 'Front Page Large Feature'); if($categories){ foreach($categories as $category) { if(!in_array($category->cat_name,$exclude)){ array_push($catArr, $category); } } $len = count($catArr); foreach($catArr as $cat){ $output .= '<a href="'.get_category_link($cat->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $cat->name ) ) . '">'.$cat->cat_name.'</a>'; $i++; if($i < ($len - 1)){ $output .= $separator; } } echo($output); }else { echo 'General'; } ?> <span class="pull-right"> <?php //comments_number('No Comments', 'One Comment', '% Comments' );?> </span></i></small></p> <hr> <?php the_excerpt();?> <p><i><a href="<?php echo get_permalink(); ?>">Continue Reading...</a></i></p> <hr> </div> <?php endwhile; // end of the loop. ?><br> <!-- Ten items per page --> <div class="pagination"> <?php posts_nav_link( ' ? ', 'Older Articles', 'Newer Articles' ); ?> </div> </div> <!-- Selection of side-bar banners begins --> <div class="offset1 span3"> <?php include('sidebar-block-our-work.php'); ?> <?php include('sidebar-block-receive.php'); ?> </div> <!-- Selection of side-bar banners ends --> </div> </div> <!-- News Feed Ends --> <!-- Banner Block Begins --> <?php include('sidebar-banner-our-community.php'); ?> <!-- Banner Block Ends --> <?php get_footer(); ?>
Any help would be greatly appreciated!
- The topic ‘WordPress search with quotations returning to homepage’ is closed to new replies.