实时搜索:
$the_query = new WP_Query( array( \'s\' => esc_attr( $_POST[\'keyword\'] ), \'post_type\' => \'custom_type\', \'sentence\' => \'true\' ));
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post(); ?>
<a href="<?php echo esc_url( post_permalink() ); ?>"><?php the_title();?></a>
<?php endwhile;
我为类别创建了一个自定义帖子类型“custom\\u type”,为标签创建了两个分类法“custom\\u cat”(Hierarchy=true),为标签创建了“custom\\u tags”(Hierarchy=false)。我需要通过自定义标记创建实时搜索。
我试图设置“taxonomy”=>“custom\\u tags”,但该参数被忽略,search按关键字返回了所有“custom\\u type”帖子。有人知道解决方案吗?