Speed up search query that searches in post meta?
Speed up search query that searches in post meta?
Speed up search query that searches in post meta?
a more proper way to solve this as pointed in many cases would be : //include search form in header include(locate_template(‘template-header-search.php’)); //include search form in body include(locate_template(‘template-body-search.php’));
I recently had a similar problem and it had something to do with the query’s posts_per_page parameter. Try setting it explicitly, like so: function custom_search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘posts_per_page’, 10 ); // Try setting it to the number you’ve set in the WordPress admin (Settings > Reading). … Read more
Rewrite URL for Search + Special Characters / Umlaute
Search Replace Database ONLY for posts of certain category?
Found it thanks for the investigation tips guys! So when it was doing the meta_value search the search term was showing up the meta_key _wp_old_slug‘s meta_value
Default HTML5 Form . Add theme support function wpdocs_after_setup_theme() { add_theme_support( ‘html5’, array( ‘search-form’ ) ); } add_action( ‘after_setup_theme’, ‘wpdocs_after_setup_theme’ ); WordPress will render its built-in HTML5 search form: <form role=”search” method=”get” class=”search-form” action=”<?php echo home_url( “https://wordpress.stackexchange.com/” ); ?>”> <label> <span class=”screen-reader-text”><?php echo _x( ‘Search for:’, ‘label’ ) ?></span> <input type=”search” class=”search-field” placeholder=”<?php echo esc_attr_x( … Read more
Get posts by similar names and categories
Isn’t this easily to be achieved by checking if ?s= is set ? You do have to output the results of this search on the same page, by using the post archive link as action url. if ( isset( $_GET[s] ) { // show posts }
After searching through two dozen blog posts I was able to combined several approaches and make this work. function my_search_by_title_only( $search, $wp_query ) { if ( ! empty( $search ) && ! empty( $wp_query->query_vars[‘search_terms’] ) ) { global $wpdb; $q = $wp_query->query_vars; $n = ! empty( $q[‘exact’] ) ? ” : ‘%’; $search = array(); … Read more