0
votes

I purchased a plugin that allows buddypress users to add new pages to their profile and ran into an issue that caused me to reach out to the developers, only to realize that this seems to be an issue with every custom post type, and is not isolated to a single plugin. This very well may be a Wordpress thing, but this is extremely inconvenient and I was wondering if there was a way around this.

When users add new pages to their profile, even if the permalink is unique, on the chance that a user names their page the same name as another user, a number denoting a duplicate is added to the permalink. For example: User 1 makes a page titled Services (mysite.com/user1/services User 2 also makes a page titled Services (mysite.com/user2/services-2) I have changed the post type permalink to include /%author%/%post-name% which works correctly, and changes the permalink, except a number is still added to the end if more than one page has the same title. How can I stop this from happening if the pages are made by different authors?

This was the message I sent to the developers of the plugin, who informed me the issue isn’t really the permalinks, it’s more that the pages are a custom post type and thus beholden to the same slug rules that normal pages have, where if you created 2 pages named “contact”, the second one gets “contact-2” and so on.

I had assumed the user’s buddypress/author page would count as a parent page, but it seems that’s not the case. This appears to occur on my own custom post types as well as any custom post type plugin I happen to use, but I had never tested that until just now. Even if the permalink itself is unique, custom post types cannot have the same title/slug even if created by different users and I can see this hindering user experience.

Does anyone have any thoughts?

1

1 Answers

0
votes

Adding author to permalink does not make the page unique. Pages are defined as individual objects and their permalinks are related only to the last section of the link.

The system compares only the post name (the slug) not the full URL or permalink.

mysite.com/user1/{post_slug}

If the {post_slug} is the same as another post slug then the system adds incrementation.

Just to clarify the answer - The post permalink is defined by the post slug and not the permalink itself.

What I would do in your case is to set these pages to an ID-based permalink.