• My permalink structure is
    /%category%/%post_id%/%postname%
    Which gives nice URLs, like
    https://myblog/news/5833/this-is-my-post

    Problem is, if a post doesn’t have a category, the permalink doesn’t work. I’m not a rewrite expert but the following rewrite rule doesn’t seem to fix it:
    '/([0-9]{1,})/' => 'index.php?p=$matches[1]'

    What am I missing?

Viewing 3 replies - 1 through 3 (of 3 total)
  • How can a post not have a category? Any post that is not assigned to a category will simply be filed under the default category (“Uncategorized” in a default install).

    Thread Starter donzacharias

    (@donzacharias)

    You would think so! Somehow posts that are uncategorized are showing up with nothing in that first position in the URL. Maybe WP doesn’t put “Uncategorized” in the URL if you use it in a permalink?

    I wrote my own little plugin/filter to change the category chooser list to be radio buttons so that authors can only choose one category. As a result it looks like the default category is unchecked in the list so it is easy to save posts as uncategorized. I think maybe I can just make sure that it is always checked, that way I can prevent this situation.

    Thread Starter donzacharias

    (@donzacharias)

    To clarify, I checked again and the posts in question are in the category Uncategorized, and nothing is showing up in the first position of the permalink.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Workaround for ?tegoryname% in permalink if post has no category?’ is closed to new replies.