Viewing 5 replies - 16 through 20 (of 20 total)
  • i m getting this error:
    Parse error: parse error, unexpected ';' in /home/httpd/vhosts/deydas.com/httpdocs/404.php on line 131
    abhi.

    Did you take the code directly from the authors site? If so it has been styled and you need to use unstyled text. Ie the curly quotes are not acceptable. Try copying the code directly from this post.
    <?
    $search_term = substr($_SERVER['REQUEST_URI'],1);
    $search_term = urldecode(stripslashes($search_term));
    $search_url = 'https://davidblog.ws/blog/index.php?s=';
    $full_search_url = $search_url . $search_term;
    $full_search_url = preg_replace('/ /', '%20', $full_search_url);
    $full_page = implode("", file($full_search_url));
    print_r($full_page); die();
    ?>

    yes david, i’ve unstyled it but still nothing…
    abhi.

    FYI, in case anyone cares, I fixed my directory problem and made one more improvement. Now it only makes the new search term if it’s a 404 error (this page handles all errors). So in my conditional cases that evaluate getenv("REDIRECT_STATUS") I added this code to part for 404’s:
    $search_term = substr($_SERVER['REQUEST_URI'],1);
    $find = array ("'.html'", "'.+/'", "'[-/_]'") ;
    $replace = " " ;
    $new_search = preg_replace ( $find , $replace , $search_term );

    and then in the search field I just put <?php echo ($new_search); ?> which only has a value if it was a 404 error.

    Im loving the hack, but i’ve noticed a lot of searches for “/archives/2004/12/27/post-name/”, which when searched for doesn’t bring up any posts, how would i only have it search for “/post-name/”?

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘404 Search Function for WordPress’ is closed to new replies.