The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →A broken custom post type (CPT) URL is usually caused by one of four things: the post type was registered without usable rewrite settings, WordPress is using stale rewrite rules, another Page or route owns the same slug, or the web server is not passing pretty URLs to WordPress. Register the CPT on init, confirm its public-query settings, save Settings → Permalinks, check for slug collisions, and then investigate Apache, Nginx, or custom rewrite code if the 404 remains.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
Identify exactly which permalink is failing
Test both a single entry and the archive before changing code. A single URL such as /library/example-book/ and an archive URL such as /library/ are generated from related but distinct settings. If the archive works while every single entry returns 404, inspect the single-post rewrite and queryability settings. If both fail, start with registration and the rewrite cache. If every pretty URL on the site fails, the web server is a more likely cause than the CPT itself.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
WordPress All-in-One For Dummies | $25.40 | Buy on Amazon |
| 2 |
|
WordPress for Beginners 2026: A Visual Step-by-Step Guide to Mastering WordPress (Webmaster Series) | $19.99 | Buy on Amazon |
| 3 |
|
WordPress For Dummies (For Dummies (Computer/Tech)) | $16.59 | Buy on Amazon |
As an Amazon Associate I earn from qualifying purchases.
- Single CPT URL returns 404: check the registered slug,
publicly_queryable,query_var, rule collisions, and stale rules. - Archive returns 404 but singles work: verify
has_archiveand the archive slug. - Old slug still loads after a change: flush the rewrite rules, then confirm that no redirect or cached page is serving the old route.
- All pretty permalinks fail: inspect
.htaccess, Apachemod_rewrite, or the equivalent Nginx configuration.
Use a controlled test matrix
Open one published CPT item, the CPT archive, a normal post, and a normal Page. Test while logged out, preferably in a private window, and clear any page or reverse-proxy cache. This tells you whether the defect follows the post type, the URL base, or the entire site. Also test a newly published item: a single old entry can have a stale cache or an unusual post status that a new item does not.
Register the custom post type with usable rewrite settings
register_post_type() determines whether WordPress creates rewrite rules and which path it uses. The post type should be registered on the init hook on every request, before rewrite rules are flushed or requests are resolved.
#1 Best Overall
function register_book_post_type() {
register_post_type( 'book', array(
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => 'library',
'with_front' => false,
),
'show_in_rest' => true,
) );
}
add_action( 'init', 'register_book_post_type' );
With this registration, a published entry can use a path such as /library/example-book/, while the archive can use /library/. The exact result also depends on the site’s permalink structure and whether another route already claims that path.
What each important argument controls
| Argument | Effect on URLs | What to verify |
|---|---|---|
public |
Sets a group of visibility defaults, including front-end availability. | Use true for a normal public content type, then verify the individual query settings rather than relying only on this shortcut. |
has_archive |
Creates an archive route for the post type. | Set it to true or provide a deliberate archive slug when an archive is required. |
rewrite |
Controls generated permastructs. | Use an array for a custom slug; use false only when you intentionally do not want generated pretty rewrites. |
rewrite['slug'] |
Sets the base path used by single entries and, normally, the archive. | Choose a stable, unique path such as library; changing it changes public URLs. |
rewrite['with_front'] |
Controls whether the site’s front base is prepended to the CPT structure. | Set false when the CPT should not inherit a front base such as a blog prefix. |
rewrite['feeds'] and rewrite['pages'] |
Control feed and paginated archive structures. | Specify them only when you need behavior different from the defaults. |
publicly_queryable |
Determines whether front-end requests can query the post type. | A false value prevents normal public single URLs even if the type is otherwise registered. |
query_var |
Controls the query variable used to resolve requests. | If it is false, the post type cannot be loaded through its query-var URL. |
rewrite => false |
Disables generated rewrites for the type. | Do not use this when you expect ordinary pretty CPT URLs. |
A CPT can appear in the administration area and still be unreachable on the front end. Check publicly_queryable and query_var explicitly when the registration looks correct but a single URL remains a 404. A type intended only for internal data may deliberately set these values to false; in that case, a front-end 404 is expected rather than a permalink defect.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Keep the post type key and public slug distinct
The internal key, such as book, is not necessarily the public URL base, such as library. Keep the key stable for code, database queries, and migrations, and change the public slug only when a URL change is intentional. Avoid punctuation, spaces, and a base already used by a Page, taxonomy, feed, or another plugin.
Regenerate WordPress rewrite rules after registration or slug changes
WordPress keeps a cache of custom rewrite rules. Registering a new CPT, changing its rewrite slug, adding a rewrite rule, or installing a component that changes routes does not automatically make every existing cached rule current.
Use the safe administrative flush
- Sign in to WordPress.
- Open Settings → Permalinks.
- Click Save Changes without changing the permalink structure.
- Open a CPT archive and a single entry in a private browser window or after clearing any page cache.
Visiting or saving the Permalinks screen triggers a rewrite flush. The screen can also warn when WordPress cannot write the site’s .htaccess file. If the URLs begin working immediately, the problem was a stale rule cache rather than the CPT data itself.
Do not assume that changing the permalink structure to a different option and changing it back is necessary. A single save is the normal administrative repair. If a cache or CDN still serves the old response, purge that layer after the flush and test the origin directly when possible.
Recommended Free Tools
Flush once during plugin activation
A plugin that owns a CPT should register it before flushing on activation. This makes the generated rules include the new post type.
add_action( 'init', 'register_book_post_type' );
register_activation_hook( __FILE__, 'my_plugin_activate' );
function my_plugin_activate() {
register_book_post_type();
flush_rewrite_rules();
}
The activation callback is the appropriate place for a plugin-owned flush because it runs when the feature is installed or enabled. If a plugin changes its slug later, provide a controlled upgrade routine or instruct the administrator to save the Permalinks screen once. A deactivation hook can flush after the plugin removes its routes, provided the post type is no longer needed and the lifecycle is deliberately managed.
Why flushing on every request is a mistake
flush_rewrite_rules() is expensive. Calling it on every page load increases database and file-system work and can create avoidable load on busy sites. Do not put it directly in a template, shortcode, or an unguarded init callback. Flush only after the relevant registration or rewrite change, during activation, deactivation, deployment, or a deliberate administrative repair.
Find and remove slug collisions
A Page, taxonomy, or another route can use the same path as the CPT. WordPress then has competing interpretations for a request such as /events/ or /portfolio/. The result can be a 404, an unexpected Page, or an archive that works only intermittently after other changes.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Rank #2
- Write down the CPT rewrite slug and archive slug.
- Search Pages for the same path, including trashed content if the site recently used that name.
- Check other CPTs, taxonomies, custom rewrite rules, multilingual route mappings, and permalink-management settings.
- Rename the conflicting Page or change the CPT’s single/archive slug.
- Save Settings → Permalinks again.
- Retest both a single entry and the archive.
Changing only the visible Page title may not change its URL. Inspect the Page permalink or slug field and make the path itself unique. Likewise, changing a CPT registration slug does not automatically redirect old public URLs; plan redirects separately if the old address has been indexed or shared.
Check more than the archive name
A taxonomy base can collide with a CPT base even when no Page appears to use it. Review category and custom-taxonomy rewrite slugs, attachment bases, author bases, feed names, and routes generated by multilingual or membership plugins. A short generic word is more likely to be reused, so a deliberate namespace can prevent future conflicts.
Inspect custom rewrite rules and rule order
Sites that use add_rewrite_rule(), custom taxonomies, multilingual routing, or permalink-management extensions can introduce rules that capture a CPT request first or send the wrong query variables. A valid CPT registration can therefore coexist with a broken request path.
Review custom rules
- Confirm the rule’s regular expression matches the intended path and does not also match the CPT base.
- Check whether the rule sends the correct post type and slug query variables.
- Review whether the rule is added at the intended priority; an earlier, broader rule can win before a later CPT rule is reached.
- Regenerate rules after modifying the code. Saving the Permalinks screen is the administrative method.
When debugging, temporarily disable one custom routing component at a time, flush once, and retest. This isolates the owner of the collision without permanently removing unrelated functionality. Keep a record of each change so a production deployment can be reversed cleanly.
Check the web server when WordPress settings are correct
Pretty permalinks require the web server to pass requests to WordPress. If the CPT is public, the slug is unique, and the rules have been regenerated but every pretty URL still fails, inspect the server rather than repeatedly flushing WordPress.
Apache checks
- Verify that Apache’s
mod_rewritemodule is enabled. - Confirm that the site’s virtual host permits the rewrite directives used by WordPress, commonly through the appropriate
AllowOverridesetting. - Check that the document root contains the expected
.htaccessfile and that the web server can read it. - Use Settings → Permalinks to see whether WordPress reports that
.htaccessneeds updating.
A writable file is not enough if the virtual host ignores it. Ask the hosting administrator to verify the active document root and Apache configuration when the file appears correct but requests still return 404.
Nginx and other server configurations
Nginx does not process Apache .htaccess files. The equivalent rewrite or try_files configuration must be present in the server block and must send unknown paths to WordPress’s front controller. Managed environments may generate this configuration outside the WordPress dashboard. Provide the administrator with the failing URL, the working or failing archive result, and confirmation that the CPT rules were regenerated.
Separate origin errors from application errors
A WordPress-generated 404 normally uses the site theme’s 404 template. A web-server 404 may have a different response body, headers, or logging pattern. Compare an invalid URL with the CPT URL, inspect server logs if available, and ask the host whether the request reaches PHP. If it never reaches WordPress, changing register_post_type() cannot solve it.
Use a rewrite inspector to see what WordPress actually generated
When the cause is not obvious, Rewrite Rules Inspector can display the current permalink structure, registered custom post types and taxonomies, and the rules WordPress currently knows about. Compare the expected CPT path with the generated list:
- If no rule for the CPT exists, revisit registration, the
rewriteargument, and whether the type is registered before the flush. - If a rule exists but points to an unexpected query, inspect custom rules and query variables.
- If the expected rule appears and WordPress resolves it correctly but the server still returns 404, move to server configuration.
The tool’s documented soft flush uses flush_rewrite_rules(false). A soft flush is useful during diagnosis when you want to regenerate the in-memory or database rules without unnecessarily rewriting the server configuration. Use a full flush only when the server file must also be updated and the environment permits that change.
Rank #3
Inspectors are diagnostic aids, not substitutes for correct registration. Remove or restrict diagnostic tools on production sites when they are no longer needed, and never expose rule-management capabilities to untrusted users.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common symptoms and what they usually mean
| Symptom | Likely area | First action |
|---|---|---|
| Archive and singles both 404 | Registration, rewrite cache, or server | Confirm init registration, then save Permalinks. |
| Archive works, singles 404 | Single rewrite or queryability | Check publicly_queryable, query_var, and single-slug collisions. |
| Singles work, archive 404 | Archive setting or collision | Verify has_archive and its archive slug. |
| Old URL still works after a slug change | Cache, redirect, or duplicate rule | Purge caches, inspect redirects, and confirm the new rule set. |
| Every pretty URL fails | Apache, Nginx, or document root | Have the host verify rewrite support and front-controller routing. |
A repair sequence that minimizes risk
- Record the symptoms. Test the archive, one single entry, an unrelated Page, and an unrelated post. Note status codes and whether the failure affects only the CPT.
- Confirm registration. Ensure the function runs on
init, the post type key is stable, and the rewrite slug is deliberate. - Check queryability. Verify
publicly_queryableis not false andquery_varis not disabled for a normal front-end CPT. - Check archive intent. Set
has_archiveappropriately and verify the archive slug does not collide with a Page or taxonomy. - Regenerate rules once. Save Settings → Permalinks and retest in a private window.
- Inspect collisions. Review Pages, taxonomies, custom rewrite code, multilingual mappings, and permalink tools.
- Inspect generated rules. Use a rewrite-inspection tool if the expected rule is still missing or points to the wrong query.
- Escalate to the server. Have the host check Apache
mod_rewrite,.htaccess, Nginx rules, document root, and virtual-host settings. - Plan redirects for changed slugs. Once the new route works, preserve valuable old links with deliberate redirects rather than expecting WordPress to create them automatically.
Choose the fix by scope and operational risk
| Fix | Best for | Safety and persistence | Owner |
|---|---|---|---|
| Save Settings → Permalinks | A stale global rewrite cache after registration or a slug change. | Low-risk administrative action; persists until another rewrite change. | Site administrator. |
Activation-time flush_rewrite_rules() |
A plugin that introduces or owns a CPT. | Controlled lifecycle operation; survives reactivation and deployment when coded correctly. | Plugin developer. |
| Soft flush during diagnosis | Checking whether missing rules are the immediate cause. | Less invasive than rewriting server files; still should not run on every request. | Developer or administrator. |
| Slug change | A Page, taxonomy, or CPT owns the same path. | Resolves the conflict but changes public URLs; redirects may be needed. | Site owner and developer. |
| Server configuration repair | WordPress rules are present but pretty URLs fail site-wide. | Highest operational scope; requires host-level access and testing. | Hosting or systems administrator. |
The least invasive option is usually a Permalinks save. A code change is appropriate when registration is wrong; a slug change is appropriate when ownership is ambiguous; and host intervention is appropriate when WordPress has the expected rules but requests never reach its front controller. Choosing the smallest scope reduces the chance of breaking unrelated routes.
Free tools Windows power users keep installed
One-click scans. No signup required.
Prevent the problem on future deployments
- Keep the CPT key and public slug stable unless a URL migration is intentional.
- Register the CPT on every request before any flush or rewrite inspection.
- Flush only during activation, deactivation, a versioned migration, or a deliberate administrative repair.
- Reserve unique namespaces for Pages, CPTs, taxonomies, feeds, and custom routes.
- After deployment, test one single CPT URL, the archive, pagination if enabled, feeds if enabled, and an unrelated pretty URL.
- Document whether the site uses Apache, Nginx, a reverse proxy, or a managed configuration so a WordPress-side fix is not mistaken for a server-side repair.
- When changing a public slug, prepare redirects and update menus, XML sitemaps, internal links, and external integrations.
- Record the expected archive and single URL patterns in deployment notes so a missing rule is noticed immediately.
Frequently Asked Questions
Why does my custom post type archive work but each single post returns 404?
Check the CPT’s publicly_queryable and query_var values, confirm that rewrite is not false, and look for a collision on the single-post base. Then save Settings → Permalinks to regenerate rules.
I changed the CPT slug, but the old URL still loads. Why?
A stale rewrite cache, redirect, page cache, or duplicate route may still serve the old address. Save the Permalinks screen, purge caches, inspect redirects, and remember that WordPress does not automatically create redirects for changed CPT slugs.
Does registering a CPT automatically create working permalinks?
Registration creates the intended structures only when the type is registered on init with usable rewrite and query settings. Existing cached rules still need to be regenerated after a new CPT or slug change.
Should I call flush_rewrite_rules() on every request?
No. Flushing is expensive and can add database and file-system work to every page load. Use the plugin activation or deactivation lifecycle, a versioned migration, or a deliberate administrative repair.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsWhat if Settings → Permalinks does not fix any pretty URL?
Check Apache mod_rewrite, .htaccess permissions and overrides, or the Nginx try_files and front-controller configuration. Ask the host to verify the document root and virtual-host/server-block settings.
Can a WordPress Page break a CPT archive?
Yes. A Page, taxonomy, another CPT, or custom rewrite rule using the same path can win the routing decision or produce a 404. Make the public slug unique and flush rules afterward.
What does rewrite => false do?
It disables generated pretty rewrites for that post type. If you expect ordinary CPT URLs, use a rewrite array with a deliberate slug instead.
Do feeds and pagination need separate troubleshooting?
They use structures controlled by the feeds and pages rewrite options. If singles and archives work but only feed or paginated URLs fail, inspect those options and regenerate rules.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe Bottom Line
Start with the CPT registration: it must run on init, use a deliberate unique slug, and allow public queries when front-end URLs are required. Save Settings → Permalinks once, check Pages and other routes for collisions, and never flush on every request. If the expected rule exists but pretty URLs still fail site-wide, the remaining fix belongs in Apache, Nginx, or the hosting configuration.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




