Try this in your functions.php
, and change news
for whatever you want to be blocked in your site.
add_action('wp', 'check_search');
function check_search() {
global $wp_query;
if (!$s = get_search_query())
return false;
if (preg_match('/news/', $s)) {
$wp_query->set_404();
status_header(404);
get_template_part(404);
exit();
}
}
Hope it helps.
Related Posts:
- Default WP search excluding specific characters, is it possible?
- Exclude posts with certain meta data from search results
- How to exclude one post format from search result?
- Consistent and Admissible Heuristics
- How do you make Vim unhighlight what you searched for?
- How to create live autofill search?
- Empty search returns home page, how to return not found search page?
- Empty search input returns all posts
- Insert DIV container below 1st search result
- How to search for users based on added user metadata
- Search by Post ID and display content of the post in search result
- Let user change posts per page
- WP User Query with search columns and meta query
- Get user role by using user_id in buddypress
- Turning Broken URLs Into Search Terms?
- Create multiple Search functions for posts / custom post types and everything
- Search uses index.php instead of search.php on renaming search field from “s”
- Set default text for the_search_query();
- How to add WooCommerce SKU to search query?
- Which template holds what to display when search returns nothing
- What are the different options for excluding certain post types from search results?
- Is_search not working on search results page
- Search in post title and custom fields
- How to change users smart quotes to dumb quotes in search bar?
- Making a list of post tags in string
- Trim the search result around the search word
- Searching custom fields is removing search on the post_title column
- Edit search results in order to advertise
- Search function works improperly
- Is there a wordpress plugin enabling an autocomplete search box, then jump to page?
- Date_query problems
- WordPress, fetching users with an exact match in a string of comma separated values in user_meta
- search form redirects to home
- How can I hide uncategorized products from search results?
- Exclude html from search results (image names, etc.)?
- documentation for wordpress 3.7 keyword
- WordPress Search not picking up text provided by a Plugin
- Get Adjacent post by search query
- How to exclude pages from WP search based on page title
- What does wordpress search, search?
- How to combine two get_users() array?
- How to get started?
- Search not working. Appending a “
- Search posts by Tag
- Improved WordPress search functionality and search form plugin
- Change Twentyeleven Search Form Text
- redirected to the login screen when I do a blank search
- Add Google custom search to wordpress.com [closed]
- Changing default wp search string
- How do I exclude a specific page (and child pages) from the search results?
- Sort WP Search results by date
- How to pass data to wordpress page (without GET parameter)
- Cannot pass ‘S’ parameter more than two letters
- Check If search query contains something?
- Localization of WP theme
- Show search count by post type
- How to have multiple instances of the same taxonomy in a search form
- WP + Google analytics = /search?
- Alter BuddyPress member search to include search on added profile fields [closed]
- Enhancin 404 to contain a search from URL
- Checkboxed term search
- Searching for one letter returns extra empty post
- Search using ACF repeater
- search custom table in wp database with searchform
- How to track searches using the REST API?
- REST API: Search products only in the names
- content-search.php duplicating the output for a certain post type
- Form for search pages by meta datas
- WordPress REST API Search decoded URL with cyrillyc symbols
- Hide Search Form above results
- searchform.php not included by get_search_form when using wp_dropdown_categories
- Modify wordpress search to search only pages and load matched page not search results
- WordPress search post using unicode
- Create search box on Archive Custom post type
- How to pass variable to get_search_form()?
- Problem with search results page
- Why the search results are wrong in search posts form?
- Search result page as a new page
- Search isn’t displaying all results
- How to use regular page template for search results?
- Search Engine Visibility Issue in WordPress
- Page has no template
- Allow users to search for other users in WordPress
- Auto search field without buttons, shows first result from search page
- How to Search Users on the Base of Latitude and Longitude in Users meta_key and meta_value
- How to stop the search results from loading the wrong template?
- search form display no result
- WordPress search not able to find text in url
- Search & Replace trailing strings
- Page/Post path in Search Results
- Customizing Home Page with Pagelines Platform
- Make search result returned only from tags! [duplicate]
- WordPress search form and input type=”image”
- How to search pdf attachment?
- Website Search Results Not Showing Images
- How do I find a shortcode stored in wordpress?
- Return excerpt on Search
- Attached file how can i work the wp_query to search for related names
- Exclude category in search results in functions.php
- How to quickly search posts by title in Admin interface