我在我的网站上使用 Ajax search lite,但我有两个带有特殊数据的自定义数据表。我想将它们添加到 Ajax search lite 插件的查询中。这些不是自定义帖子类型或字段!
如何将这些数据表添加到查询中?
/* custom header search */
add_action('wp_ajax_custom_search_data' , 'custom_search_data');
add_action('wp_ajax_nopriv_custom_search_data','custom_search_data');
function custom_search_data(){
if($_POST['keyword']) {
$the_query = new WP_Query( array( 'posts_per_page' => 5, 's' => esc_attr( $_POST['keyword'] ), 'post_status' => 'publish','post_type' => array('post','product','page') ) );
if( $the_query->have_posts() ) {
?>
<div class="search_result_data"><span> Search Result</span>
<ul class="search_ul">
<?php while( $the_query->have_posts() ): $the_query->the_post(); ?>
<li><a href="<?php echo esc_url( post_permalink() ); ?>"><?php the_title();?></a></li>
<?php endwhile;
wp_reset_postdata();
?>
</ul>
</div>
<?php }else { ?>
<div class="search_result_data">
<span> Data Not found </span>
</div>
<?php }
}
exit();
}