There are several plugins for WordPress that allow to improve the features and performance of the function "Search". Almost all the plugins available are useful and attractive feature highlight search terms in the search results. If you're not going to appensantire further your WordPress installation, but do not want to give up everything to a similar feature, here's how to easily implement a "highlights" of termii search results.
. Open the file search.php , and insert the following code inside the loop center or, if you use a standard theme, look for the div class="entry" . In practice we would modify the output of the result after a search:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <div class="entry"> <? Php / / The variable $ s is the search string / / For example: parolaA parolaB explode ( " " , $s ) ; $ Keys = explode ("", $ s); / / Fetch the summary, not the whole text get_the_excerpt ( ) ; $ Excerpt = get_the_excerpt (); / / Wrap in the summary the search words / / With <strong class="evidenzia"> parolaA </ strong> preg_replace ( '/(' . implode ( '|' , $keys ) . ')/iu' , '<strong class="evidenzia">\0</strong>' , $excerpt ) ; $ Excerpt = preg_replace ('/ ('. implode ('|', $ keys). ') / iu', '<strong class="evidenzia"> \ 0 </ strong>', $ excerpt); / / Monster altered the summary "the_excerpt" , $excerpt ) ; echo apply_filters ("the_excerpt", $ excerpt); ?> ?> ">Leggi tutto</a></p> <p class="right more"> <a href = "<? php the_permalink ()?>"> Read more </ a> </ p> </ Div> |
giallino simile ad un evidenziatore… o quello che volete) nel risultato se presenti nel riassunto . All the words entered in the search field will be highlighted (the CSS class evidenzia you can define it as desired, for example with a background similar to a yellow highlighter ... or whatever) in result if present in the summary. This procedure, in fact, it is limited to act only on the first part of our post (excerpt), not all of its contents. However, it is a good alternative to installing an additional plugin.










[...] Learn more visit the source: Undolog.com "Very short trick: WordPress, the results highlight ... Related articles: Undolog.com" Very short trick: WordPress, exclude pages and post [...]
[...] Very short trick: WordPress, highlight the results of a search a little trick to raise the profile of the top keyword searches on our blog in search results. [...]
Really interesting, thanks.
Looking at your blog I see that is really well done, you insert between the sites to visit my
Hello and congratulations
[...] Blogging @ @ Very short trick: WordPress, highlight the results of a search [...]
@ YesWEBcan:
thank cool to post
Bohh .. in search.php data entry .. I'm not indicate where you can insert this code?
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<div id="content">
<div class="post">
<div class="title">
<h2> Rezultatele cautarii </ h2>
</ Div>
( have_posts ( ) ) : ?> <? Php if (have_posts ()):?>
( have_posts ( ) ) : the_post ( ) ; ?> <? Php while (have_posts ()): the_post ();?>
; ?> "> <Div class = "post content" id = "post-<? Php the_ID ();?>">
? rel = "nofollow" > " rel=" bookmark " title=" Permanent Link to <?php the_title ( ) ; ?> "> <?php the_title ( ) ; ?> </a></h3> <h3> <a href = "<? php the_permalink ()? rel =" nofollow ">" rel = "bookmark" title = "Permanent Link to <? php the_title ();?> "> <? php the_title () ;?> </ a> </ h3>
; ?> <? Php the_excerpt ();?>
</ Div>
; ?> <? Php endwhile;?>
<div class="navigation">
'Previous Entries' ) ?> </span> <span class="next-entries"> <?php previous_posts_link ( 'Next Entries' ) ?> </span> <span class="previous-entries"> <? php next_posts_link ('Previous Entries')?> </ span> <span class="next-entries"> <? php previous_posts_link ('Next Entries')?> </ span>
</ Div>
: ?> <? Php else:?>
It seems <h3> rau nu am gasit nimic.Va rugam incercati din nou. </ h3>
; ?> <? Php endif;?>
</ Div> <! --/content ->
</ Div> <! --/content ->
; ?> <? Php get_sidebar ();?>
; ?> <? Php get_footer ();?>
@ Sp0nky: I did not understand the question ...
Giovambattista my dear, in your article writing and you can open the search.php inserirsci the following code inside .....
, per non sbagliare ho chiesto dove inserisco il codice postato di te? As you can see in my
search.php, I havediv class="entry", to avoid mistakes I asked where I post the code you posted?@ Sp0nky: Ok, you have to put into practice in line 14 instead of:
This is because - as written in the post - you're not using the standard theme. Each theme, in fact, may occasionally alter the HTML standard WordPress, although many issues remain the nomenclature
entry.thanks a lot amico.Hai many interesting things in here I have to try and put sito.Li practica.A soon.
Hello and thanks for this nice article! ^ ^
I have a problem:
I want in the search results there is both the_excerpt (), and both the_content (),.
in this way:
the_content ();
the_excerpt ();
Thank you ^ ^
PS: Is there any code to improve the search?