[wp-trac] [WordPress Trac] #24294: empty post title generates 404 error

WordPress Trac noreply at wordpress.org
Fri Oct 18 16:45:21 UTC 2024


#24294: empty post title generates 404 error
--------------------------+----------------------
 Reporter:  marcopanichi  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Permalinks    |     Version:  3.5.1
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------

Comment (by digitalkkot):

 This issue occurs because of how WordPress generates permalinks when a
 post is initially published without a title. In your steps, a numeric
 permalink is assigned when the title is empty, which gets cached or
 stored. Later, when the title is added and the post is updated, the
 permalink might not update correctly, leading to a 404 error when trying
 to access the post via its category.
 [[Image(ticket:24294:desktop.png, 0px,
 link=https://bildzeitungheute.de/)]]
 **Root Cause:**
 When a post is created without a title, WordPress defaults to generating a
 numeric permalink (post ID). This is cached or stored.
 After updating the post with a title and category, the expected behavior
 is that WordPress updates the permalink to reflect the new title.
 However, the permalink might not update properly, leaving the system
 pointing to the original numeric one, which causes a mismatch and results
 in a 404 error when navigating to the post through the category.
 **Potential Fixes:**
 Resave Permalink Structure: Go to Settings > Permalinks and click Save
 Changes without modifying anything. This often forces WordPress to flush
 the rewrite rules and can resolve 404 errors for posts with updated
 titles.

 **Post Slug Update:** Edit the post and manually update the slug
 (permalink field) to match the title, then update the post again.

 **Custom Rewrite Rules:** If the issue persists, custom rewrite rules
 might be required. This can be done by adding specific logic to the
 theme's functions.php file to force a permalink update whenever a post's
 title is changed.

 **Database Cache Clearing:** Some caching plugins or database
 optimizations may cause stale permalinks to persist. Clearing the cache or
 using database optimization plugins can help ensure the new permalink is
 reflected.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/24294#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list