How can I remove the search window?

I searched through all the files in the theme for the word “search” and tried removing that command from entry.php and entry-summary.php. None of that had an effect. I also tried removing the search.php file, that had no effect. To save you grief, any edits to the core files provided by WordPress will potentially break … Read more

Show only “Pages” – not posts – on search page

Setting the post type at pre_get_posts can solve this. You can set it like below- function the_dramatist_search_only_page($query) { if ($query->is_search && !is_admin() ) { $query->set(‘post_type’,array(‘page’)); } return $query; } add_filter(‘pre_get_posts’,’the_dramatist_search_only_page’); Hope it helps.

How to make wordpress Dynamic Search-Bar from Predesigned Static Html Search-Bar?

Yes, it’s pretty easy to make our static HTML Search-Bar dynamic. First, wrap up our <input />tag with <form> </form> tag mentioning action=”” and mehotd=”” Second, identify the default key of wordpress and assign it in name=”” attribute of input tag. To be specific, the code would be like this: <form method=”GET” action=”<?php bloginfo(‘home’); ?>”> … Read more

Display post matching the exact search term

Here’s a solution that I came up with that uses a hidden field on the search form which we will later check in our filters to modify WP’s default search/redirect behavior. This is the search form I used. Note the addition of the hidden field barcode-reader with a value of 1. I added the search … Read more

Date_query problems

Since your code returns the posts belonging to 5 years ago, then I assume your problem is in the conditionals, since none of them are run. The form elements must have a name if you want to get their values in the back-end. Your select lacks a name, and you are trying to get its … Read more

WordPress Search matching hyphenated words

It is possible to filter search terms before they are submitted to the actual query using the query_vars hook. So in your case you would do something like this: add_filter (‘query_vars’, ‘wpse307005_filter_search’, 10, 1); function wpse307005_filter_search ($args) { preg_replace (‘Spiderman’,’Spider-Man’,$args[s]); preg_replace (‘Spider man’,’Spider-Man’,$args[s]); return $args; } Where $args[s] holds the search string.

Keep query string in url after executing a serch

It’s hard to say how to do it exactly in your case, because we don’t know how your form is generated… But in general you have to add a hidden input to that form. So if you use searchform.php in your theme, then add something like this to it: <input type=”hidden” name=”name” value=”<?php echo esc_attr( … Read more

Redirect All Search Links Containing – to + on WordPress

You can do something like the following at the top of your .htaccess file to replace all – with + that occur after the /search/ path segment in the requested URL: RewriteRule ^(search/[^-]*)-([^-]*-.*) /$1+$2 [N] RewriteRule ^(search/[^-]*)-([^-]*)$ /$1+$2 [R=302,L] The first RewriteRule loops (internally) until all except 1 hyphen has been replaced with +. The … Read more

WordPress does not find author pages in search

I used this extra query in search.php: $search_string = esc_attr( trim( get_query_var(‘s’) ) ); $wp_user_query = new WP_User_Query( array( ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘first_name’, ‘value’ => $search_string, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘last_name’, ‘value’ => $search_string, ‘compare’ => ‘LIKE’ ) ) ) ); With a custom loop: <?php … Read more

Transliterating search term in another language

If you have PHP’s Intl extension installed, you can use the wonderful Transliterator class. I get some pretty good results, like this: $t = Transliterator::create(‘Latin-Greek’, Transliterator::FORWARD ); var_dump( [ ‘alfa’ => $t->transliterate(‘alfa’), ‘alpha’ => $t->transliterate(‘alpha’), ] ); Both these greeklish forms give me “άλφα”. I don’t know how it knows where to put the accent, … Read more