Archive permalink for custom taxonomy term gives 404
-
I have added a couple of custom taxonomies (called Section and Column) to my theme. When registering these taxonomies, I set “rewrite” to true so that I would get category-style permalinks for my taxonomies. For example, https://www.example.com/section/section1/ would be the permalink for the archive page for the Section named Section1.
These permalinks work fine as long as there is at least one post associated with the taxonomy term being used in the permalink. However, if there are no posts associated with the term, browsing to the archive permalink results in the 404 page. The behaviour I would have expected is that instead of a 404, I would get the archive page with the “No posts” message, as happens if you browse to the archive permalink for a Category that contains no posts.
I used the WordPress Internal Rewrite viewer plugin to view my rewrites, and these are the rewrite rules that are in place for the “section” custom taxonomy:
[section/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?section=$1&feed=$2 [section/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?section=$1&feed=$2 [section/(.+?)/page/?([0-9]{1,})/?$] => index.php?section=$1&paged=$2 [section/(.+?)/?$] => index.php?section=$1
As far as I can see, these are identical to the rewrite rules in place for Categories. I tried visiting the “ugly” permalink for one of the sections in question (i.e. https://www.example.com/index.php?section=section1). This displayed the archive page with the “No posts” message, as I would expect.
So my question is – why does the “pretty” permalink not work when the “ugly” permalink it is supposedly redirecting to does work properly? Is there any way I can find out what the “pretty” permalinks are actually redirecting to (i.e. which .php template(s) are being used to process the request)? Is there something else I am missing?
Thanks,
David
- The topic ‘Archive permalink for custom taxonomy term gives 404’ is closed to new replies.