Tuesday, January 3, 2023
HomeWordPress DevelopmentSearch key phrase retailer in customized meta key

Search key phrase retailer in customized meta key


I’ve search subject with my customized publish. Now I would like, when folks search i’ll retailer the important thing into customized meta worth, How am i able to do this.

perform eazydocs_search_results() {
    $posts = new WP_Query( [
            'post_type'         => 'docs',
            's'                 => $_POST['keyword'] ?? ''
        ]
    );
  
    if ( $posts->have_posts() ):

        whereas ( $posts->have_posts() ) : $posts->the_post();
            ?>
            <div class="search-result-item" onclick="doc.location='<?php echo get_the_permalink(get_the_ID()); ?>'">
                <a href="<?php echo get_the_permalink(get_the_ID()); ?>" class="title">
                    <?php
                    if ( has_post_thumbnail() ) :
                        the_post_thumbnail('ezd_searrch_thumb16x16');
                    else :
                        ?>
                        <svg width="16px" aria-labelledby="title" viewBox="0 0 17 17" fill="currentColor" class="block h-full w-auto" position="img"><title id="title">Constructing Search UI</title><path d="M14.72,0H2.28A2.28,2.28,0,0,0,0,2.28V14.72A2.28,2.28,0,0,0,2.28,17H14.72A2.28,2.28,0,0,0,17,14.72V2.28A2.28,2.28,0,0,0,14.72,0ZM2.28,1H14.72A1.28,1.28,0,0,1,16,2.28V5.33H1V2.28A1.28,1.28,0,0,1,2.28,1ZM1,14.72V6.33H5.33V16H2.28A1.28,1.28,0,0,1,1,14.72ZM14.72,16H6.33V6.33H16v8.39A1.28,1.28,0,0,1,14.72,16Z"></path></svg>
                    <?php endif; ?>
                    <span class="doc-section">
                        <?php the_title(); ?>
                    </span>
                    <svg viewBox="0 0 24 24" fill="none" shade="white" stroke="white" width="16px" stroke-width="2" stroke-linecap="spherical" stroke-linejoin="spherical" class="block h-auto w-16"><polyline factors="9 10 4 15 9 20"></polyline><path d="M20 4v7a4 4 0 0 1-4 4H4"></path></svg>
                </a>
                <?php eazydocs_search_breadcrumbs(); ?>
            </div>
            <?php
        endwhile;
        wp_reset_postdata();
    else:
        ?>                        
        <div> 
            <h5 class="error title"> No outcome discovered! </h5> 
        </div>
        <?php
    endif;
    die();
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments