• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

How To Replace A WordPress Category Archive With A Page

Bhagwad Park

Published on: May 25, 2022

Categories: WordPress 6

Despite the tremendous success of the Gutenberg editor, it hasn’t been extended to the category and tag pages. As a result, the category pages are boring, anemic, and are little more than a glorified list. I tried for a long while to see if I could force WordPress to load a new page instead of a category using the same URL as the existing category page. And I finally found a way to do it! So here it is.

A Flexible Solution  in Case things Change

I could have just used an easy solution by redirecting my category pages to a new page via a 301 redirect. But while this is easy, it’s also shortsighted. One day, WordPress will bring the Gutenberg editor to categories and tags, and when that happens, I want to just copy/paste my page content into the category or page editor and move on with life.

Using a redirect means our URLs will change when this happens. So let’s see how to do it.

Setting the Rules – What I Want to Achieve

Right now, my category archive page looks like this:

https://nameheroreview.com/blog/category/webhosting
https://nameheroreview.com/blog/category/anothercategory

I want each of these URLs to load a page of my choosing. A page that I can edit using Gutenberg. I don’t want any existing URLs to change, and I don’t want my breadcrumb URLs to be affected.

Step 1: Create a Dummy Parent Page with the slug “category”

The first step is to create a top-level page with a slug called “category”. This page is a dummy and doesn’t do anything. You can leave it blank. Make sure the slug matches what you see in your category archives.

Save your changes.

Step 2: Create a Child Page of the “category” Parent

In step 2, create another page for each category archive that you want to replace. Make all of them direct children of the parent dummy category page that you created in Step 1. Like this:

Importantly, ensure that the slug for these child pages exactly matches the slug for each of your categories.

Save your changes. Don’t worry about how the slug structure when you first create the page. Publish your page, reload the editor, and now you’ll see that the slug structure has changed to:

websitename.com/parentpage/childpage

What we’ve done here is we’ve created a page with exactly the same URL structure as the category page!

Step 3: Add the Code to Give Priority to the Page Instead of the Category

Unfortunately, this still doesn’t work. When you load the URL, the category page takes priority over the page URL. So we need to add some code to change this. To learn how to add code, check out my tutorial on how to insert custom code snippets in WordPress.

add_filter( 'request', 'alter_the_query' );

function alter_the_query( $query_vars ) {
	 // Ignore if in the admin
    if(is_admin()) {
        return $query_vars;
    }

    // If asking for a category
    if(isset($query_vars['category_name'])) {
        // save the slug
        $pagename = $query_vars['category_name'];
		switch($pagename) {
			case "webhosting":
			case "anothercategory":
				$query_vars = array('pagename' => "category/$pagename");
		}
    }
    return $query_vars;
}

In the above code, I’ve created two lines like this:

case "webhosting":
case "anothercategory":

Each of these represents a category page that I want to replace with a new page. For each additional category that you change, add another line similar to these two. It would have been easier for me to check and see if any pagename matched the category name, but I wanted to keep the loop as efficient as possible.

In the code, I do the following:

  1. If loading the admin, exit
  2. If loading a category, check if the slug matches any of our pages
  3. If yes, then create a query with the URL slug of the page name, and we’re done!

Save your changes, and if all goes well, your category links will now all redirect to the specific page you’ve chosen. Once WordPress brings Gutenberg editing to the category area, you merely need to copy the content over from the page to the category page, delete the above code, and move on with your life.

I hope you found this useful!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Joomla vs. WordPress: Which One Is Better?

In this post, we’ll consider five differences between Joomla and WordPress and how you might go forward with setting up a WordPress website.

Blogger vs. WordPress: Which One to Use?

Let's compare WordPress and Blogger across five key areas. Then, we'll show you how to set up a professional blog with WordPress.

How To Back Up Your WordPress Site (And Why You Should Do It Today)

In this post, we’ll take a closer look at why backups matter. We’ll also show you different ways to back up your WordPress website.

How To Start A Newsletter In WordPress

Check out our complete guide on why and how you should start your own newsletter in WordPress.

Reader Interactions

Comments

  1. James says

    September 12, 2022 at 4:54 pm

    Thanks for this, I have been trying to find a great solution to this problem for awhile. I am not using Gutenberg but I am using Elementor and SEOPress and both have limitations when dealing with Category Pages. This is great as it allows me to maintain my permalink structure.

    Reply
  2. William von Wenzel says

    September 21, 2022 at 2:19 pm

    Oh my god, has this always been available? I’ve tried so many other ways to do this, and they all end up being exceedingly complicated. Thank you so much for this tutorial!

    Reply
  3. R says

    November 13, 2022 at 12:59 pm

    Didn’t work for me, I was using elementor page builder. Since both slugs are the same, the elementor got confused and couldn’t return a preview of the page I created under the same slug. Once I activated custom plugin with the code I found in this article, the category instead of returning an element page was returning 404 page. Once I deactivated the plugin, it was returning the regular category page.

    Reply
  4. Roger Perkin says

    January 7, 2023 at 7:31 pm

    Didn’t work for me, when I created the new page to replace the category it just created the url as domain.com/category-page-2/

    I was unable to create a matching url

    Reply
  5. Rene says

    January 24, 2023 at 5:13 am

    Hi, thank you very much, it works fine.

    Unfortunately if you use an individual permalink structure for your posts like: /%category%/%postname%/ , it doesn’t work anymore.

    Do you have a solution for this?

    Reply
  6. Vero says

    August 29, 2023 at 1:14 pm

    Awesome ! Thank you so much !

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA