-
Notifications
You must be signed in to change notification settings - Fork 1
/
404.php
executable file
·40 lines (34 loc) · 1.25 KB
/
404.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php header("HTTP/1.1 404 Not Found"); ?>
<?php get_header(); ?>
<h2>We couldn't find that page, but we'll try to help.</h2>
<?php
$search_term = substr($_SERVER['REQUEST_URI'],1);
$search_term = urldecode(stripslashes($search_term));
$find = array ("'.html'", "'.+/'", "'[-/_]'") ;
$replace = " " ;
$search_term = trim(preg_replace ( $find , $replace ,
$search_term ));
$search_term_q = preg_replace('/ /', '%20',
$search_term);
$search_url =
'http://www.betterexplained.com/index.php?s=';
$full_search_url = $search_url . urlencode($search_term);
?>
<p>Suggested results for "<?php echo $search_term;
?>":</p>
<?php $my_query = new WP_Query("s=" . $search_term_q); ?>
<ul>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><h2><a href="<?php the_permalink();
?>"><?php the_title(); ?></a></h2>
<p><?php the_excerpt(); ?></p>
<p><a href="<?php the_permalink(); ?>">Read
more...</a></p>
</li>
<?php endwhile; ?>
</ul>
<?php if (! $my_query->have_posts() ){?>
Sorry, no matching results were found.
<?php } ?>
<script src="http://feeds.feedburner.com/~s/Betterexplained?i=<?php the_permalink() ?>" type="text/javascript" charset="utf-8"></script>
<?php get_footer(); ?>