Php 如何按帖子标题和剩余帖子匹配后搜索帖子?
我想搜索文章标题完全匹配后,从文章内容或类似的匹配,例如,我想搜索“怀孕”的答案应该是第一个完全匹配的文章标题和匹配后的文章标题,如“怀孕”或从文章内容搜索。下面是我的搜索代码,请指导我Php 如何按帖子标题和剩余帖子匹配后搜索帖子?,php,wordpress,search,Php,Wordpress,Search,我想搜索文章标题完全匹配后,从文章内容或类似的匹配,例如,我想搜索“怀孕”的答案应该是第一个完全匹配的文章标题和匹配后的文章标题,如“怀孕”或从文章内容搜索。下面是我的搜索代码,请指导我 <?php $args = array ( 's' => $s, 'category__in' => $category, 'year' => $year, 'monthnum' => $monthnum, 'paged' => $pa
<?php
$args = array (
's' => $s,
'category__in' => $category,
'year' => $year,
'monthnum' => $monthnum,
'paged' => $paged,
'order' => $sortby,
'tax_query' => $filterq,
'post_status' => 'publish',
'orderby' => 'title',
);
$query = new WP_Query($args) ;
// print_r($query);
if ( $query->have_posts() ) :
echo '<ul>';
while ( $query->have_posts() ) : $query->the_post();
if(mom_option('search_page_ex') == true) {
if (is_type_page()) {
continue;
}
}
?>
<li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article">
<?php if (mom_post_image() != false) { ?>
<figure class="post-thumbnail"><a href="<?php the_permalink(); ?>">
<?php mom_post_image_full('search-grid'); ?>
<span class="post-format-icon"></span>
</a></figure>
<?php } ?>
<?php if( mom_post_image() != false ) {
$mom_class = ' class="fix-right-content"';
} else {
$mom_class = '';
}
?>
<div<?php echo $mom_class; ?>>
<h2 itemprop="name"><a itemprop="url" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="entry-content">
<p>
<?php global $post;
$excerpt = $post->post_excerpt;
if($excerpt==''){
$excerpt = get_the_content('');
}
echo wp_html_excerpt(strip_shortcodes($excerpt), 115);
?> ...
</p>
</div>
<?php if($post_head != 0) { ?>
<div class="entry-meta">
<?php if($post_head_date != 0) { ?>
<time class="entry-date" datetime="<?php the_time('c'); ?>" itemprop="dateCreated"><i class="momizat-icon-calendar"></i><?php echo mom_date_format(); ?></time>
<?php } ?>
<?php if($post_head_commetns != 0) { ?>
<div class="comments-link">
<i class="momizat-icon-bubbles4"></i><a href="<?php comments_link(); ?>"><?php comments_number(__( '(0) Comments', 'framework' ), __( '(1) Comment', 'framework' ),__( '(%) Comments', 'framework' )); ?></a>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</li>
<?php endwhile;
echo '</ul>'; ?>
...