Für mehrere Suchbegriffe; ?s=hello+world
Wordpress Arbeit finden "Hallo Welt" wie the_title
, the_content
Beiträge!
Hello Anna
wordpress kein Ergebnis liefert! Ich möchte alle Schlüssel verwenden:
"Hallo Welt" , "Hallo" , "Welt"
Vielleicht array('hello world','hello','world');
aber es übersteigt meine exp.! Ist es in einer einzigen Schleife möglich, die Abfrage zu teilen und mehrere Abfragen zu senden? Gibt es jemanden, der zu diesem Thema helfen kann? z.B. ?s=
, $_GET
Gesucht muss etwas gewesen sein, um mehr Ergebnisse für mehrere Abfragen aufzurufen!
Behoben: Suche und ergebe alle Schlüssel;
<?php
$the_keys = preg_split('/\s+/', str_replace('-',' ',get_query_var('s')),-1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$total_keys = count($the_keys);
$the_query = new WP_Query(array('post_type'=>'nothing'));
if($total_keys>1){
for($i = 0; $i<=$total_keys; $i++) {
$the_query_mask = new WP_Query(array('s' => $the_keys[$i]));
$the_query->post_count = count( $the_query->posts );
$the_query->posts = array_merge( $the_query->posts, $the_query_mask->posts );
}
} else {
$the_query= new WP_Query(array('s' => get_query_var('s')));
}
if ($the_query->have_posts()) : ?>
Hinweis:'post_type'=>'nothing'
brauche nur Array zusammenführen!
Vielleicht möchte jemand wie ich Fuzzy Logic Ergebnisse
Ich löste diesen Weg: "search.php
"
<?php
$the_keys = preg_split('/\s+/', get_query_var('s'),-1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$total_keys = count($the_keys); // Count the search term
$the_query = new WP_Query(array('s' => get_query_var('s')));
// IF have multiple term and havent a result
if($total_keys > 1 && $the_query->post_count < 1){
// Loop for total term count, if found post break it! <3
for($i = 0; $i < $total_keys; $i++) {
//Set the new array term value
$the_query = new WP_Query(array('s' => $the_keys[$i]));
//if found post break it! <3
if($the_query->post_count>0) break;
}
}
// List of my Level 2 filter posts :)
if ($the_query->have_posts()) : ?>
......
<?php
endwhile;
endif;
?>
Normalerweise:
?s=hello+baby
=> finde wahr ?s=hello
=> finde wahr ?s=baby
=> finde wahr ?s=hello+whats+up
=> finde falsch ?s=hey+baby
=> finde falsch suchen, Jetzt arbeiten und finden z. ?s=hello+whats+up
=> finde wahr