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>';
|
$excerptRet .= $excerpt . ' ...</p>';
|
||||||
|
|
||||||
return $excerptRet;
|
return $excerptRet;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function search_excerpt_highlight() {
|
function search_excerpt_highlight() {
|
||||||
|
|
||||||
$length = 32;
|
# Length in word count
|
||||||
$text = wp_strip_all_tags( get_the_content() );
|
$excerptLength = 32;
|
||||||
$query = explode(' ', get_search_query());
|
|
||||||
|
$text = wp_strip_all_tags( get_the_content() );
|
||||||
|
|
||||||
|
# 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);
|
||||||
|
|
||||||
print_r($query);
|
|
||||||
|
|
||||||
echo generate_excerpt($text, $query, $length);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue