Redo search
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 16 Jul 2015 17:55:36 +0000 (13:55 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 16 Jul 2015 17:55:36 +0000 (13:55 -0400)
put check for the searchType into the seaorch page and skip showing page
post_types if searchType is blog

root/functions.php
root/search.php

index 7fae8c9..8edc962 100644 (file)
@@ -102,17 +102,6 @@ if (!function_exists('glm_get_clientinfo_option')) {
     }
 }
 
-function SearchFilter($query) {
-    if(isset($_GET['searchType'])) {
-        $searchType = $_GET['searchType'];
-        if ($searchType == 'blog' && !is_admin()) {
-            $query->set('post_type', 'post');
-        }
-    }
-    return $query;
-}
-add_filter('pre_get_posts','SearchFilter');
-
 /**
  * glm_offcanvas_menu
  *
@@ -215,19 +204,19 @@ add_action('init', 'mytheme_init', 10);
 
 function mytheme_search_loop() {
   while ( have_posts() ) : the_post(); ?>
+
     <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
       <?php thematic_postheader(); ?>
       <div class="entry-content">
         <?php thematic_content(); /* We will replace this next */ ?>
+
       </div>
       <?php thematic_postfooter(); ?>
   </div><!-- .post -->
+
   <?php endwhile;
 }
 
 add_action('thematic_searchloop', 'mytheme_search_loop');
-// End of the Contextual/Highlight Search functions 
+// End of the Contextual/Highlight Search functions
 ?>
index e380968..12f2771 100644 (file)
@@ -7,6 +7,7 @@
     <div class="row">
         <div id="blog-posts-over" class="small-12 medium-9 columns">
             <?php if(have_posts()) : while(have_posts()): the_post();?>
+                <?php if (is_search() && (isset($_GET['searchType']) && $_GET['searchType'] == 'blog') && ($post->post_type=='page')) continue; ?>
             <div class="row content search-result-container">
                 <div class="small-11 small-centered columns">
                     <article id="<?php the_ID()?>" <?php post_class()?>>
@@ -14,8 +15,8 @@
                             <h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h1>
                             <span class="meta date">Posted on <?php the_time('F jS, Y') ?></span>
                         </header>
-                        
-                                                            
+
+
                 <!-- Start of the Contextual/Highlight Search -->
                                 <?php
                                 // Configuration
@@ -68,9 +69,9 @@
                                 </p>
                                 <p>
                                   <a href="<?php the_permalink() ?>" rel="bookmark">Read this entry</a>
-                                </p>  
+                                </p>
                 <!-- End of the Contextual/Highlight Search -->
-                
+
                         <?php //echo (function_exists('the_advanced_excerpt')) ? the_advanced_excerpt(): the_excerpt(); ?>
                         <footer class="entry-meta small-12 medium-6 medium-push-3 center">
                             <?php
             <?php } ?> <!-- end empty query check -->
         </div>
     </div>
-    <?php get_footer(); ?>
\ No newline at end of file
+    <?php get_footer(); ?>