<input type="text" placeholder="Search..." value="<?php echo isset($_GET['s_q_fulltext']) ? esc_attr($_GET['s_q_fulltext']) : ''; ?>" name="s_q_fulltext"> <?php $keyword = isset($_GET['s_q_fulltext']) ? sanitize_text_field($_GET['s_q_fulltext']) : ''; global $wpdb; $keyword = esc_sql($keyword); $sql = " SELECT DISTINCT p.ID FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id WHERE p.post_type IN ('post', 'page') AND p.post_status = 'publish' AND ( p.post_title LIKE '%$keyword%' OR p.post_content LIKE '%$keyword%' OR pm.meta_value LIKE '%$keyword%' ) "; $post_ids = $wpdb->get_col($sql); $args = array( 'post_type' => ['post', 'page'], //'s' => $keyword, 'post__in' => $post_ids, ); $search_query = new WP_Query($args); ?> <?php if (!empty($keyword)): ?> <?php if ($search_query->have_posts()): ?> <div data-pad="2" class="me-block me-PanelCol search-height me-max-width" id="UwYEobJ5xSOSFJC5JLMkxXA" data-mod="MEBuild2.ParallaxScroll" data-opt="{}"> <div class="underlay"></div> <div class="overlay"></div> <div class="row me-max-width collapse"> <div class="column me-iwrap small-12 medium-order-1"> <div class="overlay"></div> <div class="underlay"></div> <div data-pad="0" class="me-block me-SearchSolrFilterResults" id="U53w2SU9WSFSjovg3pydCww"> <div class="row collapse me-max-width small-up-1"> <?php while ($search_query->have_posts()): $search_query->the_post(); ?> <?php get_template_part('template-parts/content', 'search'); ?> <?php endwhile; ?> <?php the_posts_navigation(); ?> <?php wp_reset_postdata(); ?> </div> </div> </div> </div> </div> <?php else: ?> <?php get_template_part('template-parts/content', 'none'); ?> <?php endif;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter