You probably saw this tutorial coming if you saw my last article Great 404 Pages?
In this tutorial I’ll show you how to make a WordPress 404 page. It will not only be funny, but also informative.
If you don’t know, a person is sent to a 404 page if they try to go to a URL that doesn’t exist. If you have a 404 page they’ll see something useful instead of an error page.
Here is my 404 page New Think Tank 404. I’ll show you exactly how I made it. I’ll also show you how to:
Here are links to the previous parts of this tutorial series if you missed them:
<?php get_header(); ?>
<?php get_sidebar(‘first’); ?>
<div id=”mainContent”>
<br /><br />
<img src=”http://www.newthinktank.com/wp-content/uploads/2011/08/404-Error.png” width=”700″ alt=”Page Not Found” />
<div>
<?php echo(“Sorry I can’t find that page?”); ?>
</div
<?php $numposts= wp_count_posts()->publish;
if (0 < $numposts) $numposts = number_format($numposts); ?>
<h2><?php echo ‘Check out the ‘ .$numposts. ‘ articles below’; ?>
</h2>
<ul id=”archive-list”>
<?php
$myposts =get_posts(‘numberposts=-1’);
foreach($myposts as $post) : ?>
<li><?php the_time(‘m/d/y’) ?>: <a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php get_footer(); ?>
When I copied this code I got a php error at line 6. When I deleted that line I got an error at line 8. Why would that happen?
Do a find and replace with your text editor that replaces the back quotes with regular quotes and it will work.
It’s a security thing that wordpress does. Sorry about that
I get the following error code:
Parse error: syntax error, unexpected T_STRING in /home/swindonl/public_html/wp-content/themes/swindonlabour/404.php on line 17
Now that I’ve copied in your code I can’t get my old code back.
Any ideas how to fix?
Replace all of the back quotes ‘ & ” with regular quotes and it will work. WordPress automatically changes those for security reasons. It will work then
Thanks, that did it!
I’m glad it worked. Sorry I didn’t mention that