我在Wordpress中显示结果时遇到问题WP_Query
. 这个问题很简单,但我不是程序员,所以很难解决。
因此,我有一个自定义字段,其值如下1-1-1-1
和2-1-1-1-1
例如例如,当我搜索时1-1-1-1
这也给了我第二个结果,这是我不想看到的。我只想在搜索结果中显示精确匹配。有人能帮我吗?
代码:
<?php $paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
global $wp_query;
$query = new WP_Query( \'meta_key=wpcf-resitevtags\' );
$query = $wp_query->query;
if (!is_array($query)) parse_str($query, $query);
$custom_query = new WP_Query(array_merge($query, array(\'posts_per_page\' => $gantry->get(\'search-count\'), \'meta_key\' => \'wpcf-resitevtags\', \'posts_per_page\' => 22, \'paged\' => $paged)));
?>
<?php if($custom_query->have_posts()) : ?>
<?php if($gantry->get(\'search-page-title\')) :
?>
<?php endif; ?>
<?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>
<?php
//$title = strip_tags(get_the_title());
$content = strip_tags(strip_shortcodes(get_the_content(false)));
$excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
$keys = explode(" ",$s);
//$title = preg_replace(\'/(\'.implode(\'|\', $keys) .\')/iu\', \'<span class="search-excerpt">\\0</span>\', $title);
//$content = preg_replace(\'/(\'.implode(\'|\', $keys) .\')/iu\', \'<span class="search-excerpt">\\0</span>\', $content);
//$excerpt = preg_replace(\'/(\'.implode(\'|\', $keys) .\')/iu\', \'<span class="search-excerpt">\\0</span>\', $excerpt);
?>