WordPress Custom Post Types: When They Break
Custom Post Types power complex WordPress sites β from portfolios to course platforms. But they can be the source of frustrating bugs.
The Dreaded 404 on CPT Pages
In Resolve Intermittent ACF 404 Errors, CPT pages were randomly returning 404s. The root cause was a permalink flush issue.
Sorting and Pagination
Fix Sorting & Pagination of Custom Post Type β the archive page showed incorrect results because the main query conflicted with a custom WP_Query.
PHP Widget Integration
In Fix PHP Widget, a custom widget displaying CPT data was crashing because it wasn’t checking for empty results.
Best Practices
- Always flush permalinks after registering CPTs
- Use
pre_get_postsfor archive modifications - Add proper
has_archiveandrewriterules - Test with the REST API to verify data structure
Need CPT help? Hire me on Upwork.


Really helpful guide! Solved my issue quickly.
Glad it worked for you!
Bookmarked this for future reference. Clear and well-explained.
Thank you! Hope it continues to be useful.
Really helpful guide! Solved my issue quickly.
Glad it worked for you!
This is exactly what I needed! I was getting 404 errors on my custom post types after updating WordPress. Turns out my CPT registration was missing the rewrite flush. Your tip about flushing rewrite rules after CPT changes fixed it instantly. Thanks for the clear walkthrough!
Glad it helped! Flushing rewrite rules is one of those things that trips up even experienced developers. If you ever run into pagination issues with CPTs, check the posts_per_page setting in your custom query as well.
I’ve been struggling with ACF fields not showing up on my custom post type archive pages. The section about using get_field() with the post ID parameter was the missing piece for me. Really well-written guide.
Thanks! Yes, ACF can be tricky on archive pages β always pass the post ID explicitly in the loop. Also worth noting that ACF fields won’t appear in REST API responses by default; you’ll need to enable ‘Show in REST’ on the field group.
Quick question β does the rewrite flush trick work for CPTs registered via ACF’s built-in CPT feature (new in ACF 6.1)? Or does it only apply to CPTs registered with register_post_type() in PHP? I’m using ACF-registered CPTs and still getting occasional 404s.
Great question! ACF 6.1+ CPTs handle rewrite rules automatically, but you may still need to manually flush after changing the slug. Go to Settings β Permalinks and just click Save β that forces a flush. If 404s persist, check if you have a page with the same slug as your CPT archive β slug conflicts are a common cause.