2026年11月12日
2026年11月12日
WordPress Category Page Not Showing or 404: What to Check
This article is a localized edition of the Japanese original. Read the Japanese original
When a WordPress category page (a category archive such as /category/news/) doesn't display correctly, where to look depends on the symptom.
| Symptom | Main cause | Section |
|---|---|---|
| Every category returns 404 | Rewrite rules or server configuration | 1 |
| Only some categories return 404 | Wrong slug in the URL, or a changed category base | 2, 3 |
| Only page 2 and later return 404 | Mismatch between posts per page and the theme's own query | 4 |
| The page loads but no posts appear | Post status, pre_get_posts customizations, custom post types |
5, 6 |
| The page doesn't use the template you expect | Template hierarchy | 7 |
Note that a category with no posts does not return 404; it is a normal page (status 200) that says no posts were found. You get a 404 when the category doesn't exist or when you open a page number beyond the last page.
The steps in this article assume the WordPress 6.x admin and WP-CLI as of October 2026.
1. Save the permalinks again
If every category returns 404, start by rebuilding the rewrite rules. In the admin, open "Settings → Permalinks" and click "Save Changes" without changing anything.
If you have WP-CLI, this command does the same. With --hard, it also rewrites Apache's .htaccess.
wp rewrite flush --hard
If that doesn't fix it, check the server configuration.
- Apache: Is the WordPress block in
.htaccess(from# BEGIN WordPressto# END WordPress) present, isAllowOverrideset toAll(or at leastFileInfo) for that directory, and ismod_rewriteenabled? - Nginx: Does
location /containtry_files $uri $uri/ /index.php?$args;? Nginx doesn't read.htaccess, so without this line every page except the front page returns 404.
2. Check the category slug
If only some categories return 404, check that the slug in the URL matches the category's actual slug.
wp term list category --fields=term_id,name,slug,count
In the admin, you can see it in the "Slug" column of "Posts → Categories". If you create a category with a Japanese name, the slug is Japanese too and appears in URLs percent-encoded, like %e3%81%8a.... Hand-typed links and old links to categories whose slug was changed later return 404.
3. Check the category base
The "Category base" field under "Optional" in "Settings → Permalinks" is the part placed before the category in the URL. If it is empty, category is used, giving https://example.com/category/news/.
If you change it to something like topics, the URL becomes https://example.com/topics/news/ and the old /category/news/ returns 404. If there are external links or search results pointing to the old URLs, set up redirects from the old URLs to the new ones.
If you use a plugin that removes the category base from URLs, a page or post slug that collides with a category slug can make one of them unreachable. Deactivate the plugin and see whether the symptom changes.
4. Only page 2 and later return 404
How many pages a category archive has is decided by the main query. If a theme template uses new WP_Query() or query_posts() to show a different number of posts, it links to page numbers that don't exist in the main query, so page 2 and later return 404.
To change the number of posts on category pages, don't create a separate query in the template; change the main query's count with pre_get_posts.
add_action( 'pre_get_posts', function ( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_category() ) {
$query->set( 'posts_per_page', 12 );
}
} );
Put this code in a child theme's functions.php or in your own plugin. See also fixing pagination 404s with pre_get_posts.
5. Check post status and category assignment
If the page loads but shows no posts, check whether the category actually has published posts. Pass the slug, not the category name, to --category_name.
wp post list --category_name=news --post_status=any --fields=ID,post_title,post_status,post_date
Posts whose post_status is draft (Draft), pending (Pending Review) or future (Scheduled) don't appear on category pages. private (Private) posts appear only to logged-in users who are allowed to read them.
6. Check pre_get_posts and custom post types
Is a customization affecting category pages?
If a theme or plugin modifies the main query with pre_get_posts, it can affect category pages depending on its conditions. Code like the following, which changes the post type without any condition, causes problems.
// Problematic: affects every main query (including category pages and the admin)
add_action( 'pre_get_posts', function ( $query ) {
if ( $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'product' ) );
}
} );
Exclude the admin with is_admin(), and limit the change to the intended pages with conditions such as is_home() (the main posts page) or is_category(). If you can't tell which code is responsible, temporarily switch to a default theme (such as Twenty Twenty-Five) or deactivate plugins and see whether the symptom changes. Do this on a staging site, not on the live site.
Custom post types don’t appear by default
Unless a post type is specified, category archives show only regular posts (post). Even if you enable categories for a custom post type, its posts don't appear on category pages by default. To show them, add the post type to the main query (replace news in the example with your post type name).
add_action( 'pre_get_posts', function ( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_category() ) {
$query->set( 'post_type', array( 'post', 'news' ) );
}
} );
To use categories with a custom post type, include category in the taxonomies argument of register_post_type(), or call register_taxonomy_for_object_type( 'category', 'news' ).
How exclude_from_search affects archives
Setting exclude_from_search to true in register_post_type() removes that post type from site search results. In addition, on custom taxonomy archives (taxonomies you register yourself) where no post type is specified, WordPress only queries post types whose exclude_from_search is false, so that post type disappears from those taxonomy pages too.
Category and tag archives show only post by default, as described above, so this setting doesn't affect them. To show a custom post type on category pages, specify the post type with pre_get_posts as above.
7. Check which template is used
If a category page doesn't look the way you intended, check which template is being used. Classic themes look for the following files in order and use the first one found.
category-{slug}.php(for example,category-news.phpfor the slugnews)category-{ID}.php(for example,category-5.phpfor ID 5)category.phparchive.phpindex.php
Block themes look in the templates/ folder for HTML files in the same order (category-news.html, category-5.html, category.html, archive.html, index.html). Templates edited in the Site Editor ("Appearance → Editor → Templates") take precedence over the theme's files.
If you created category-news.php and it isn't used, check that the slug in the file name matches the actual slug and, if you use a child theme, that the file is in the active theme's folder.
Related articles
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)