-
Notifications
You must be signed in to change notification settings - Fork 0
/
404.php
executable file
·87 lines (61 loc) · 2.29 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* The template for displaying 404 pages (not found).
*
* @package Festival of Trees
*
* @link http://yoast.com/wordpress-404-error-pages/
*/
/**
* Because of using post_type=any we have to manually weed out the attachments from the query_posts results.
*
* @author Joost De Valk
*
* @return WHERE statement that strips out attachment
*/
function martiandliz_strip_attachments( $where ) {
$where .= ' AND post_type != "attachment"';
return $where;
}
add_filter( 'posts_where', 'martiandliz_strip_attachments' );
get_header();
?><div id="content" class="narrowcolumn">
<h2>Can't find that page, sorry... (Error 404)</h2>
<p>Let me help you find what you came here for:</p><?php
$s = preg_replace( "/(.*)-(html|htm|php|asp|aspx)$/", "$1", $wp_query->query_vars['name'] );
$posts = query_posts( 'post_type=any&name=' . $s );
$s = str_replace( "-", " " , $s );
if ( count( $posts ) == 0 ) {
$posts = query_posts( 'post_type=any&s=' . $s );
}
if ( count( $posts ) > 0 ) {
echo "<ol><li>";
echo "<p>Were you looking for <strong>one of the following</strong> posts or pages?</p>";
echo "<ul>";
foreach ( $posts as $post ) {
echo '<li><a href="' . get_permalink( $post->ID ).'">' . $post->post_title . '</a></li>';
}
echo "</ul>";
echo "<p>If not, don't worry, I've got a few more tips for you to find it:</p></li>";
} else {
echo "<p><strong>Don't worry though!</strong> I've got a few tips for you to find it:</p>";
echo "<ol>";
}
?><li>
<label for="s"><strong>Search</strong> for it:</label>
<form style="display:inline;" action="<?php bloginfo( 'siteurl' ); ?>">
<input type="text" value="<?php echo esc_attr( $s ); ?>" id="s" name="s"/> <input type="submit" value="Search"/>
</form>
</li>
<li>
<strong>If you typed in a URL...</strong> make sure the spelling, cApitALiZaTiOn, and punctuation are correct. Then try reloading the page.
</li>
<li>
<strong>Look</strong> for it in the <a href="<?php bloginfo( 'siteurl' ); ?>/sitemap/">sitemap</a>.
</li>
<li>
<strong>Start over again</strong> at my <a href="<?php bloginfo( 'siteurl' ); ?>">homepage</a> (and please contact me to say what went wrong, so I can fix it).
</li>
</ol>
</div>
<?php get_footer(); ?>