Websites

The Undead Menace of Zombie Pages: Understanding and Eliminating Unwanted CPTs in WordPress

6 min
Posted by: Reaction
Last Updated: May 19, 2023
The Undead Menace of Zombie Pages: Understanding and Eliminating Unwanted CPTs in WordPress Image

Have you ever encountered a strange page on your WordPress site that looks like it’s come back from the dead? 🧟 These pages, often referred to as “zombie pages,” can be a result of custom post types (CPTs) that should not be displayed on a single view. Not only do these pages provide a poor user experience, but they can also negatively impact your website’s SEO. Today, we’ll explore what zombie pages are, how they can be created, and how to banish them from your website for good.

Zombie Pages and CPTs in WordPress

Imagine you’ve got a WordPress website that uses a custom post type (CPT) for testimonials. Each testimonial is added to the WP admin individually and displayed throughout various pages on your site. However, it was never intended for these testimonials to have their own indexable pages. As a result, they don’t have a specific template, making them visually unappealing and providing a bad experience for visitors who stumble upon them through a search. This situation is what we call “zombie pages.”

3 Reasons Why Zombie Pages are Bad for SEO

We all understand that a strong online presence is crucial to attracting and retaining customers. One of the main factors that contribute to your online visibility is your website’s SEO, or search engine optimization. A well-optimized site will rank higher in search engine results, making it easier for potential customers to find you.

However, zombie pages can have a detrimental effect on your site’s SEO performance. These undead pages can:

Dilute your website’s content quality

Search engines like Google use algorithms to assess the quality of a site’s content. When your site has a lot of low-quality pages, like zombie pages, it can lower your overall content score and hurt your rankings.

Increase your website’s crawl budget

Search engines allocate a certain amount of time to crawl and index your website. Zombie pages can use up valuable crawl budget, preventing search engines from finding and indexing your high-quality content.

Lead to poor user experience

When visitors accidentally land on a zombie page, they are likely to have a negative experience and leave your site without engaging further. High bounce rates and low user engagement can signal to search engines that your site is not providing valuable content, further damaging your SEO.

Identifying Zombie Pages in WordPress

To find these undead pages lurking on your site, you can review your sitemap or use Google Search Console. Both methods will reveal any indexable pages, including those pesky zombie pages. Be sure to go through each page and make note of any URLs that shouldn’t be there.

Eliminating Zombie Pages in WordPress

Disabling Single View and Creating Redirects

To put these zombie pages to rest, you’ll need to disable the single view for CPTs in WordPress. Here’s how:

Step 1: In your WordPress theme’s functions.php file, add the following code snippet:

add_action(‘template_redirect’, ‘remove_single_cpt_view’);
function remove_single_cpt_view() {
if (is_singular(‘testimonial’)) {
    global $wp_query;
    $wp_query->set_404();
    status_header(404);
    get_template_part(404);
    exit();
  }
}

function remove_single_cpt_view() {

  if (is_singular(‘testimonial’)) {

    global $wp_query;

    $wp_query->set_404();

    status_header(404);

    get_template_part(404);

    exit();

  }

}

Note: Remember to replace ‘testimonial’ with the slug of the CPT you want to disable.

Step 2: Save and upload the functions.php file to your server.

Step 3: Now that you’ve disabled the single view for your CPTs, you’ll want to create 301 redirects for those zombie pages to avoid any broken links. You can do this using the Redirection plugin in WordPress:

1. Install and activate the Redirection plugin.

2. Go to Tools > Redirection in your WordPress dashboard.

3. Click the “Add New” button to create a new redirect.

4. In the “Source URL” field, enter the URL of the zombie page.

5. In the “Target URL” field, enter the URL where you want visitors to be redirected.

6. Set the “HTTP code” to “301 – Moved Permanently.”

7. Click “Add Redirect” to save your changes.

8. Repeat this process for each zombie page you’ve identified.

Conclusion

Zombie pages can harm your website’s user experience and SEO, but with a little know-how, you can banish them for good. By disabling the single view for CPTs in WordPress and creating 301 redirects using the Redirection plugin, you’ll ensure that your site remains free of unwanted, undead content. So go on and make big things happen online by keeping your website tidy and zombie-free! 🚀

We’re here to help.

Submit a support ticket