I know it isn't good practice but I'm considering using same name slugs for some pages and categories on a site that I'm working on. It's a small site and it doesn't seem to affect anything in particular. I added one slug and page with the same name and they worked fine, but when creating a second WP forced me to rename the page (being created after the category) with an additional "-2" being added to the slug. Is there a particular order to create the pages and categories in order to avoid this? I've created similar structures before without this appearing. Also checked trash for old pages that might be using the original slug.
4 Answers
I used to do the same thing - create a page with the same name as a category to use as a faux index page.
I think I used this No Category Base plugin to remove the /category/ bit from the URL. (I think it was this plugin.)
[...] this plugin will completely remove the mandatory 'Category Base' from your category permalinks ( e.g. myblog.com/category/my-category/ to myblog.com/my-category/ ).
-
Thanks, that did it! I'm back on using WPs traditional setup now with no faux Pages retrieving the posts, then using the plugin you suggested to clean up the URLs. Nov 1, 2011 at 20:22
There is no way you can avoid this. In WordPress you cannot have two pages/categories with the exact same slug.
-
But right now I have a page called "Press" AND a category called "Press", and it's working as far as I know. The page runs a query that fetches the posts from the category (this was the only solution I could find in order to get rid of the ever-annoying "category" extra slug that gets added when using the regular archive / category for presenting the posts. Nov 1, 2011 at 9:40
-
well if you have it working, then what is all the fuzz about? but evenso, you really should avoid using same slugs as in the future you might run into trouble, for example with other plugins or whatnot. Try to alter them as per @Brad Dalton's suggestion– user2015Nov 1, 2011 at 11:56
-
I got "Press" Page and "Press" category to co-exist, but not "News" Page/Category. Anyway, I removed the Page placeholders now trying to use WP as it is intended. Nov 1, 2011 at 20:17
I know it's late, but it might help someone someday. Taken from How to Change the Category Base Prefix in WordPress.
First you would need to go in your WP-Admin Panel and go to
Settings » Permalinks
. There you would see an Optional box which allows you to change the category base prefix and the tag base prefix. (Example Below)Simply add the text that you like, and you are done. This way is guaranteed to work because it is a hard-coded option within WordPress.