I am having a hard time dealing with the tag base page.

When I go on a tag archive, the URL is as follows : http://example.com/blog/tag/tag1

But when I go to http://example.com/blog/tag

I end up with a 404.

I try redirecting /blog/tag to /blog, but then I have a redirection from /blog/tag/tag1 to /blog/tag1 which is 404 as well.

I see two solutions now :

1) Create a /blog/tag archive page that would list all tags and have a link to the /blog/tag/tag1 template (favorite solution). I know what to code inside (in php), but when I create a new page called "tag" I am unable to create a slug using a parent page (it automatically becomes /blogtag).

2) If that is not possible, to redirect /blog/tag to /blog/ but keep the /blog/tag/tag1 structure working.

Could you please help me ?

Thank you !

  • How are you redirecting? – Tom J Nowell Sep 30 '16 at 14:43
  • I copied some code I found on the internet into my .htaccess but it did not work, so I removed it. How would you do ? – Grégoire Llorca Oct 3 '16 at 9:24

Your tag archive hasn't stopped working because it never existed to begin with. WordPress displays items via the main loop and this takes 2 forms:

  • Individual Posts
  • Post archives

If you want to list the categories or tags of your site, you'll need to create a page for that and use code be it via a plugin and shortcode, or a custom template in your theme

Such a theme template could contain a redirect by using wp_safe_redirect( home_url() ); before outputting any markup

  • I tried to do it but it did not work. I created a new page called "tag" and created a php file called page-tag.php in my theme folder. Then I tried to access the example.com/projets/tag url but it was a 404 and in the wp-admin area, the page had a slug that was example.com/projetstag and not /projets/tag as I wanted to (it is impossible to add a / in the slug editor field). – Grégoire Llorca Oct 3 '16 at 9:25
  • What is the projets page? – Tom J Nowell Oct 3 '16 at 17:01
  • It is the main loop. The homepage features different content, what the company does, testimonials, etc. And then the "projets" page is a kind of portfolio for which each project is a WP post. – Grégoire Llorca Oct 4 '16 at 8:51
  • I'm not sure I understand, so projets is the root of the site? A page with a page template? A custom post type? A custom post type archive? If it's a custom post type then WP will be looking for a post of type projets with the slug tag. I think you might have muddled up your URL structure and design a little by introducing some ambiguity and clashes ( e.g. is projets/tag a projet named tag or a page named projets/tag? WP cares about these things and you need to be crystal clear about ordering and rules, usually it's much easier to avoid these issues in the first place ) – Tom J Nowell Oct 4 '16 at 15:11
  • The root of the site is www.example.com (the site is private I cannot give you the actual URL, sorry). It does not include a loop (it's a static page). The page /projets is the main loop (it displays all articles). Now, when I read a post, there are tags. If I want to see all posts using a tag, I am redirected to /projets/tag/my-tag, which works. The issue is that in my breadcrumbs and in the URL, I have the '/tag/' bit that is not a real page (404). I would like to avoid that, either by redirecting '/projets/tag' to '/projets' or by creating a '/projets/tag' that is not 404. – Grégoire Llorca Oct 5 '16 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.