Hi:
How can i turn off the search area in the theme to disallow people to search the site. Can’t find any controls for this in theme admin.
Thanks
I think you can disable the search item in the menu from the theme panel.
Theme does not control ‘core’ WP functions however, like search. You would need either a separate plugin for that, or custom function added to your functions file (or custom plugin for your functions to survive theme updates).
e.g.,
function wpb_filter_query( $query, $error = true ) {
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;
if ( $error == true )
$query->is_404 = true;
}
}
add_action( 'parse_query', 'wpb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
function remove_search_widget() {
unregister_widget('WP_Widget_Search');
add_action( 'widgets_init', 'remove_search_widget' );
HI:
I went into the theme panel and couldn’t find where search was at all. Where in the theme panel should I go? I went thru all the sections and couldn’t find anything related to hiding or turning off the search widget in the theme.
Thanks
to be clear i am not looking to impact how results display but to hide search in the theme totally.
Hm. I think we might have removed the item from the actual menu template on our sites. Removing that won’t turn off the search function, just remove from the theme. We use sidebars for iPad and desktop, and moved the search box there instead.
You’d still need to use function to remove overall search functions, as that has nothing to do with the theme.
I will be quiet and let TagDiv folk reply on how to remove the search element from the main menu; I thought they’d added a toggle for that! (doh)
-
This reply was modified 8 years by
simchris.
Yes I was surprised there isn’t simply a toggle for hiding the search on the menu as well!
Hi,
The search in the header can be disabled in the theme panel
– https://www.screencast.com/t/h7C2QdzQmt
Hi:
Thanks for the reply. I am on an earlier version of the theme and don’t see that option. Is it elsewhere?
If it’s not there then the version you are using does not have the option. Remove the search by hiding it with CSS or in the code. With CSS it would depend on the theme version you are using, the code has changed over updates. A similar topic here
– https://forum.tagdiv.com/topic/hiding-search-icon-from-top-menu/