May
11
2012

Change error 404 page

Error 404 is widely spread in the internet. With WordPress you can change information on the page, so the user won’t leave your site after getting an error.


Here’s the code you can use in your theme for 404 Error Page to help user find missing page.

<?php
$s = $wp_query->query_vars['name'];
$s = preg_replace("/(.*)-(html|htm|php|asp|aspx)$/","$1",$s);
$s = str_replace("-"," ",$s);
if (count($posts) == 0) { $posts = query_posts('post_type=any&s='.$s);
if (count($posts) > 0) { echo "<p>I'm sorry, but the page you are looking for is no longer here. Maybe you searched for <strong>this post or page</strong> ?</p>"; echo "<ul>"; foreach ($posts as $post) { ?>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<small><?php the_time(__('l, F jS, Y','fusion')) ?></small>
<p><?php the_tags(__('Tags: ','fusion'), ', ', '<br />'); ?> <?php printf(__('Posted in %s','fusion'), get_the_category_list(', '));?> | <?php edit_post_link(__('Edit','fusion'), '', ' | '); ?> <?php comments_popup_link(__('No Comments','fusion'), __('1 Comment','fusion'), __('% Comments','fusion')); ?></p>
<?php
}
}
}
?>

For additional information visit original post.

Неправильная раскладка: срфтпу уккщк 404 зфпу

Понравилась статья? Посоветуйте друзьям!

WordPress


Понравилась статья? Подпишись на рассылку по E-Mail или в RSS.