WordPress.org

Ready to get started?Download WordPress

Forums

Disable search functionality (3 posts)

  1. 98503
    Member
    Posted 5 years ago #

    What would be the best way to go about disabling search from the blog?

    It's not that I simply want to remove the search form and file, which I can do. Is there any database information specifically for search function (there used to be, I'm fairly sure, but it may not be the case any longer as I haven't seen any at a glance)? If so, how would the code be altered so that no information would be sent to/from the database regarding search function?

    Thank you.

  2. Mark
    Member
    Posted 5 years ago #

    Create a pluging that empties the 's' variable for URLs and forms - 3 possible places. Something like this:

    <?php
    Plugin Name: Disable Search
    Plugin URI: http://wpsecurity.net
    Description: This disables the search feature of WordPress.
    Author: Mark
    Version: 1.0
    Author URI: http://wpsecurity.net
    */
    $_GET['s']='';
    $_POST['s']='';
    $_REQUEST['s']='';
    ?>

    Copy that to a file in your plugins dir (maybe a filename like disablesearch.php), activate the plugin, and then try to do a search manually for a word you know exists in your site, then see if the search returns nothing. Example search URL:

    http://somerealsitename.com/?s=test

  3. Michael Clark
    Member
    Posted 4 years ago #

    You're missing the "start comment command" in front of the second line:

    /* Plugin Name: Disable Search

    Looking through my web logs I found several search engines using the WordPress search engine to search my site. I wonder if somewhere on the web is a link to my site with the search pre-defined.

Topic Closed

This topic has been closed to new replies.

About this Topic