fix search results containing double quotes
This commit is contained in:
parent
c1ca62ea2e
commit
aad50bf239
1 changed files with 16 additions and 6 deletions
|
|
@ -476,15 +476,25 @@ function generate_excerpt($text, $query, $length) {
|
|||
$excerptRet .= $excerpt . ' ...</p>';
|
||||
|
||||
return $excerptRet;
|
||||
|
||||
}
|
||||
|
||||
function search_excerpt_highlight() {
|
||||
|
||||
$length = 32;
|
||||
# Length in word count
|
||||
$excerptLength = 32;
|
||||
|
||||
$text = wp_strip_all_tags( get_the_content() );
|
||||
$query = explode(' ', get_search_query());
|
||||
|
||||
print_r($query);
|
||||
# Filter double quotes from query. They will
|
||||
# work on the results side but won't help with
|
||||
# text highlighting and displaying.
|
||||
$query=get_search_query(false);
|
||||
$query=str_replace('"','',$query);
|
||||
$query=esc_html($query);
|
||||
|
||||
$query = explode(' ', $query);
|
||||
|
||||
echo generate_excerpt($text, $query, $excerptLength);
|
||||
|
||||
echo generate_excerpt($text, $query, $length);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue