From c4eac160b6d7153b4f929b21698543d13c444b0d Mon Sep 17 00:00:00 2001 From: Ian Weller Date: Fri, 19 Jan 2018 16:22:06 -0500 Subject: [PATCH] updated the search.php I updated the search php to look more up to date. --- search.php | 147 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 45 deletions(-) diff --git a/search.php b/search.php index 76be770..f8de830 100644 --- a/search.php +++ b/search.php @@ -1,55 +1,112 @@ - - +
+
+ +

Please enter a query in the search box.

+ +

Search Results for ""

+
+ +
+
+ + post_type=='page')) continue; ?> +
+
+
> +
+

+ Posted on +
-
-

Search Results for ""

-
- -
-
-
-
- + --> -
-
-
-
- -
> -

Page:

-
- - -
- - @'), array(' ', "\n"), apply_filters('the_content', $post->post_content))) : ''); + + // Search content for terms + $terms = $wp_query->query_vars['search_terms']; + if ( preg_match_all('/'.str_replace('/', '\/', join('|', $terms)).'/i', $content, $matches, PREG_OFFSET_CAPTURE) ) { + $padding = max($min_padding, $max_length / (2*count($matches[0]))); + + // Construct extract containing context for each term + $output = ''; + $last_offset = 0; + foreach ( $matches[0] as $match ) { + list($string, $offset) = $match; + $start = $offset-$padding; + $end = $offset+strlen($string)+$padding; + // Preserve whole words + while ( $start > 1 && preg_match('/[A-Za-z0-9\'"-]/', $content{$start-1}) ) $start--; + while ( $end < strlen($content)-1 && preg_match('/[A-Za-z0-9\'"-]/', $content{$end}) ) $end++; + $start = max($start, $last_offset); + $context = substr($content, $start, $end-$start); + if ( $start > $last_offset ) $context = '...'.$context; + $output .= $context; + $last_offset = $end; + } + + if ( $last_offset != strlen($content)-1 ) $output .= '...'; + } else { + $output = $content; + } + if ( strlen($output) > $max_length ) { + $end = $max_length-3; + while ( $end > 1 && preg_match('/[A-Za-z0-9\'"-]/', $output{$end-1}) ) $end--; + $output = substr($output, 0, $end) . '...'; + } + + // Highlight matches + $context = nl2br(preg_replace('/'.str_replace('/', '\/', join('|', $terms)).'/i', '$0', $output)); ?> -
-
-
-
+

+ +

+

+ Read this entry +

+ + + +
+ $cat->name, 'slug' => $cat->slug ); + echo ', '. $cat->name .''; + } + echo '.'; + } + ?> +
+
-
- - - - - - -
+ + + +

-
- -
- +
+ + + + + + + \ No newline at end of file -- 2.17.1