<?php

    add_action('wp_ajax_advenx_search_data_fetch' , 'advenx_search_data_fetch');
	add_action('wp_ajax_nopriv_advenx_search_data_fetch','advenx_search_data_fetch');
	function advenx_search_data_fetch(){

        $search_val = advenx_sanitization($_POST['search_val']);

        $the_query = new WP_Query( array( 'posts_per_page' => 5, 's' => $search_val, 'post_type' => array('post', 'product') ) );
        if( $the_query->have_posts() ) :
            while( $the_query->have_posts() ): $the_query->the_post(); ?>
                <li class="quick_search_data_item">
                    <a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title();?></a>
                </li>
            <?php endwhile;
            wp_reset_postdata();
        else:
            echo'<p>'. esc_html__( 'No Results Found', 'advenx') .'</p>';
        endif;

        die();
}

?>