Hamza Shatela Official Website. Web Design, SEO & Online Marketing Professional.
  • BLOG
  • CONTACT

Hamza Shatela

Join The 1 Year WordPress Program
  • Home
  • Blog
  • WordPress
  • How to Improve Your 404 Page Template in WordPress
December 10, 2017

How to Improve Your 404 Page Template in WordPress

How to Improve Your 404 Page Template in WordPress

by Shatela Hamza / Sunday, 19 November 2017 / Published in WordPress
Improve Your 404 Page WordPress
When a visitor tries to access a page that does not exist, user will be redirected to 404 page. Putting some effort in understanding how to put this page into use and re-designing it to align with your brand identity, and website structure, will make your website more user friendly and will retain users from leaving your site because they ended up on a 404 page.

Some things to keep in mind for your 404 page:

  • Keep your 404 error page free of advertising
  • The 404 page should reflect the personality of the site
  • The 404 page should include a call to action or a redirect to your website
  • It be static HTML and not contain complex scripts that might create additional errors for end user
  • 404 pages should load as quickly as possible

In this article I’m going to walk you through how does a default 404 page look , and how to create a 404 page in case your WordPress theme doesn’t include a 404 page to even start with. Additionally, I will be walking you through step by step tutorial with code snits that you can copy and past to your theme.

  1. How to Create a Custom 404 Page in WordPress
  2. How to Display Recent Posts on 404 Page
  3. How to Display Random Posts on 404 Page

  1. How to Create a Custom 404 Page in WordPress

Before you start, I would recommend to backup your wordpress theme, because to create a custom 404 page template, we need to edit the 404.php file in the theme.

Now, to to take advantage of the lost click directing to your 404 page, we need to make the page more useful, I’m are going to show you how to add useful elements such as popular posts, most commented posts, recent posts, date archives, list of all categories. By enhancing your 404 you will redirect miss leaded users to the right page, or your most popular pages.

  1. How to Display Recent Posts on 404 Page

There are multiple ways to display recent posts in WordPress. The easiest way is to add a template tag in your 404 template to display your recent posts, as follows:

<?php wp_get_archives( array( 'type' => 'postbypost', 'limit' => 10, 'format' => 'custom', 'before' => '', 'after' => '
' ) ); ?>

  1. How to Display Random Posts on 404 Page

If you want to display a random list of posts on your 404 page, then you simply need to add this code in your 404 template where you want to display a random list of posts from your site.

<ul>
<?php
$posts = get_posts('orderby=rand&numberposts=5');
   foreach($posts as $post) { ?>
        <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
        </li>
   <?php } ?>
</ul>
Finally, adding a search bar as a call to action on your 404 page is a so recommended. I hope that this article was  helpful and made it clear on how to enhance the 404 page on your WordPress site. Feel free to play around with the code and experiment with different template tags to meet your needs.
Feel free to share
Shatela Hamza

About Shatela Hamza

Hamza Shatela is a web designer and online business developer. With ten years of experience in the digital marketing field. As the founder of Slide Sigma, he has worked with a series of professionals from the medical, financial, nonprofit, and entertainment industries.

What you can read next

Directory WordPress Themes
Best Directory WordPress Themes
Backup WordPress Using Plugins
Backup WordPress Website Using Plugins
install WordPress HostGator
How to install WordPress on HostGator using QuickInstall

WEBSITE HOSTING


Bluehost.com $3.95 Hosting

SEO PowerSuit

SEO PowerSuit free Downlaod

Constant Contact 60 Days Free

constant contact form downlaod

RankPay

RankPay SEO Services

SEMrush

Recent Posts

  • How to Install WordPress Tutorial

    How to Install WordPress – Complete WordPress Installation Tutorial 101

  • Multisites WordPress

    How to Install a Multisites on WordPress

  • Install WordPress using FTP

    How to Install WordPress using FTP (Manual Installation)

  • Install WordPress MOJO Marketplace

    How to Install WordPress Using MOJO Marketplace

  • Install WordPress Fantastico

    How to Install WordPress using Fantastico

Sign up and join 38,371+ of other smart subscribers. Stay up to date with weekly newsletter on market trends and stay on top of your online buiness by having an idepth knowledge of valuable softwares to boost your online business

What do you have to lose? You can unsubscribe anytime.

About

  • About Me

Additional Pages

  • Blog
  • Start a Blog for Free
  • WordPress 1 Year Program

Legal

  • Privacy Policy
  • Term & Conditions
  • Disclosure

Contact

  • Contact

My reviews and opinion on sites are ranked and reviewed on the basis of my own views and expert opinions. I use affiliate links, and I get a commission when you click on any referral website. That’s how I maintain this website. It doesn’t cost you anything. In fact, I guarantee you get the best price when you use my link. Hamzashatela.com cannot and does not present information about every site or site offer available.
© 2017 Hamzashatela. All rights reserved.

TOP