Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
  • News
  • Startups
  • Tutorials
  • SEO
  • Marketing
  • Interviews
No Result
View All Result
Dotlayer
No Result
View All Result

How To Display Random Posts on Your WordPress 404 Page To Turn Lost Visitors Into Loyal Users

November 11, 2018
in Tutorials
0 0
Share on FacebookShare on Twitter

Depending on the size and age of your WordPress website, there’s a good chance you have 404 pages. The question is how do you turn those pages into something useful for your users? There’s no benefit to just showing the user 404 pages, telling them the page is not found.

In this article, we will show you how to improve your 404-page in WordPress, you will learn how you can create a more useful 404 page that actually helps users. The 404 page in general is often the most neglected page on most sites.

In WordPress, the render the 404-page, it is handled by a template file called 404.php. The 404 page offered by WordPress is usually part of the theme. If you are not seeing a 404-page that is provided by the theme then your access or URL configuration is messed up.

To start improving the 404 page, the first thing we need to do is start by creating a custom 404-page template. This can be done by editing the 404.php file in your WordPress theme. If you are editing your theme directly, then we strongly recommend that you to at least back up your WordPress theme or website in general.

To make your 404 page more useful, we 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, etc. This will allow new users to have a quick glance at what you have to offer.

Display Random Posts on 404 Page

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

<?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>

This same query can be modified to show the most popular posts, most commented posts among others. This article describes the process of improving the 404-page on your WordPress website to make it more useful in general.

ShareTweetPin
Previous Post

How to Mount S3/Wasabi/DigitalOcean Storage Bucket on CentOS and Ubuntu using S3FS

Next Post

How to View and Delete Your Entire Mac OS X Download History Securely

Next Post

How to View and Delete Your Entire Mac OS X Download History Securely

You might also like

Mint Linux vs Ubuntu: Which is Right For You?

Mint Linux vs Ubuntu: Which is Right For You?

March 12, 2022
Net Neutrality: What is it and Why Should You Care?

Net Neutrality: What is it and Why Should You Care?

March 12, 2022
Solid State Drives – Why You Should Buy One Today

Solid State Drives – Why You Should Buy One Today

March 12, 2022

Machine Learning Algorithms Every Beginner Should Know

January 25, 2022
What Is the log4j Vulnerability, log4shell, an Example Step-By-Step Exploit and How to Fixed It

What Is the log4j Vulnerability, log4shell, an Example Step-By-Step Exploit and How to Fixed It

December 11, 2021
Simple Video Call integration into Website with Jitsi

Simple Video Call integration into Website with Jitsi

May 26, 2020
  • Terms of Service
  • Privacy Policy
  • Careers

© 2021 Dotlayer.com

No Result
View All Result
  • About Us
  • Advertise
  • Blog
  • Careers
  • Contact
  • Contact Us
  • Get Featured
  • Home Layout 1
  • Home Layout 2
  • Home Layout 3
  • Privacy Policy
  • Security
  • Services
  • Subscribe To Dotlayer
  • Terms of Service
  • Write For Us

© 2021 Dotlayer.com

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In