URL issues with WordPress

I am having some URl issues with WordPress
Basically i have different categories and for some reason whenever I have posts with exact same title…even though in “different” categories…I still have WordPress change the URl and adds like -#…where # stands for duplicate number.

like I can have links like gateway, gateway-2, gateway-3 and so on…WordPress automatically appends those numbers because they have same title…but they are all in different categories…so I need help here please….what can I do to stop wordpress from doing this and use the exact title since they are in different categories?

Thanks.

Answer

This is not fixable, and there are good reasons for this.

Say we had a post with the slug ‘apple’, resulting in /category1/apple. What your question is asking, is how would we add another post with an identical slug, such that it’s URL was /category2/apple?

If this was done:

  • If you referred to the post via its slug in a get_posts or wp_query, which post would it load? It’s ambiguous
  • Those aren’t the only URLs that work, if we loaded /post/apple, would it load the apple in category1 or category2?
  • What about /index.php?p=apple ?
  • What if a 3rd apple is added, that is in both category 1 and category 2, which apple should be used?

These issues are not trivial to overcome, and they will occur if you manage this. It is not in your interests to do this. I can understand the marketing reasoning, but it is not possible with posts from a technical standpoint.

If you wanted to do it, modifying the database would be necessary, but I strongly advise against this, as it would invoke a number of problems, and could leave you with either:

  • A broken wordpress
  • Access to the first ‘apple’ post you wrote but not the second.
  • various errors in the backend

Attribution
Source : Link , Question Author : grant tailor , Answer Author : Tom J Nowell

Leave a Comment