Turning off search

Posted in: Newspaper
Post count: 10

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

Post count: 9544

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' );

Post count: 10

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

Post count: 10

to be clear i am not looking to impact how results display but to hide search in the theme totally.

Post count: 9544

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.
Post count: 10

Yes I was surprised there isn’t simply a toggle for hiding the search on the menu as well!

Post count: 20688

Hi,

The search in the header can be disabled in the theme panel
https://www.screencast.com/t/h7C2QdzQmt

Post count: 10

Hi:
Thanks for the reply. I am on an earlier version of the theme and don’t see that option. Is it elsewhere?

Post count: 20688

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/

Viewing 9 posts - 1 through 9 (of 9 total)
The forum ‘Newspaper’ is closed to new topics and replies.