Removing filename searches when searching attachments

Approaching this from the SQL is a mistake, and instead a quick search of the official dev docs for filename reveals a filter named wp_allow_query_attachment_by_filename that is set to true by default: apply_filters( ‘wp_allow_query_attachment_by_filename’, bool $allow_query_attachment_by_filename ) Filters whether an attachment query should include filenames or not. This means you can disable querying filenames … Read more

Different date time in results of search

All the date functions reference the global $post variable, but from your code the $post variable is not being used, so that’s why the date is wrong. Try this (untested): foreach ( $total_results as $tr ) { echo get_the_time( ‘j F Y, G:i’, $tr ); }

Adding another search field in a custom search box

To add a dropdown selector for the custom field meta key “function_camere” in your WordPress search form, you can modify the wpb_demo_shortcode function to include this new dropdown. This dropdown will allow users to select a value for the “function_camere” field, which will then be used as a search criterion. Here’s how you can modify … Read more

Search page doesn’t recognise post_type=page

I found a solution in this answer here: I customised the function as follows: function page_search_filter( \WP_Query $query ) { if ( ! is_admin() ) { if ( $query->is_main_query() && $query->is_search() ) { if ( isset( $_GET[‘post_type’] ) && $_GET[‘post_type’] == ‘page’ ) { $query->set( ‘post_type’,’page’ ); } } } return $query; } add_action( … Read more

Pagination URL not good

It looks like you’ve attempted to replace the default WP_Query object for your search page by instantiating a new WP_Query object. This has two main effects: firstly you’re hitting the database twice completely unnecessarily, slowing down the page execution; and secondly default template functionality like pagination depends on the default query for the page rather … Read more

search posts by POST ID

The function you are using might not be working because WordPress’s search functionality has been updated, and it’s recommended to use WordPress’s WP_Query class to modify the main query. Here’s a better and safer way to search by post ID using pre_get_posts hook: function search_by_post_id($query) { if($query->is_search) { if(is_numeric($query->query_vars[‘s’])) { $query->set(‘post_type’, ‘any’); $query->set(‘post__in’, array((int)$query->query_vars[‘s’])); $query->set(‘s’, … Read more

Blocking spambots from Search form

You need to modify the code that processes the search to sense and block invalid attempts. You could do this by looking for a valid session number, or even a session variable that is created by the page that contains the search form. You might also try a hidden field for the search form, although … Read more

I had removed my phone number from my website footer, but months later it still appears once I look it up on google, how to remove it?

It usually takes several days (or more) for search results to be updated. First step would be to look at every single page of your site and check for the correct phone number. Then create a new sitemap.xml file, and submit that to the various search engines (like via Google Webmaster Tools). Many articles available … Read more