Permalink not working for page without title

I am testing a WordPress theme using the WordPress Theme Unit Test test data. One of the test posts has no title. WordPress generates a permalink of the form:

<my-site>/posts/14/

(my permalink structure is “/posts/%postname%/”).

Read More

The WordPress recommendation is “Post permalink should be displayed. Making the post date a permalink is a great solution.”

That’s exactly what I did. Unfortunately, when I click on the link:

  • I do not get the post in question. The page I do get appears to be the similar to the paged index of all posts, except that all non-paged posts are displayed in full, instead of as excerpts.
  • The page navigation is incorrect. The link for older posts is “/posts/14/page/2/”, which causes the same page to be redisplayed.

If I change the post slug to “post14”, it works just fine, so the problem is evidently due to the numeric slug.

Obviously I could change the slug, but that’s not a real solution. Once the theme gets out in the real world, I can’t guarantee that users will always use post titles or that they’ll know enough to change the slug.

Any suggestions?

Related posts

Leave a Reply

1 comment

  1. TL;DR: go the the edit post screen, clear the Post permalink/slug (found immediately below the Post Title field) by clicking “Edit”, and then deleting the existing text, and save.

    So, what’s happening here:

    On the site where the Theme Unit Test data are hosted, the ID of the post in question is 14. When you import the data, the ID of that post may or may not be the same.

    With posts with no Title, WordPress generates a permalink slug based on the posts’ ID. So in the original site, WordPress generated a permalink slug using the ID “14”. When you import the data, that permalink slug is retained, even though the post’s ID may change. Ergo, you get a broken permalink.

    For reference, see this still-open Trac ticket related to numeric post titles:
    http://core.trac.wordpress.org/ticket/5305