Support » Developing with WordPress » Create Duplicate Slugs for pages same page title but different content

  • Hi,

    After making some research, it seems that slugs are unique and cannot be duplicated, but what about two pages having same page title but different content and different custom fields. In other words, our website is running content in Europe different than content in Asia but this content has same title.

    How can we handle this? Is it feasible?

    I tried many ways by rewriting rules of permalinks or by using custom taxonomies in the permalink, but it seems that WordPress is interpreting only the last slug of the URL and pointing the page to the original page which has the unique slug, Ex:

    if we have these two links:
    1- http://www.alwadi-alakhdar.com/fr/recipe/int/nivig/ ( int means international )
    2- http://www.alwadi-alakhdar.com/fr/recipe/nivig/

    Both URLs have same page titles but different content, I tried the rewriting of permalink rules in functions.php, and it changes the url of first link but if we try to edit this page, it is actually pointing to the second link since the last slug is the same in both pages even though we have “/int/” in the first link.

    Any support for this will be appreciated.

    Thank you in advance

Viewing 7 replies - 1 through 7 (of 7 total)
  • It sounds like you’re really overcomplicating this.

    Why not just make two separate pages with the same content? Then you could differentiate the custom fields and slugs between them. No custom coding necessary.

    OH, wait. I misunderstood what you meant.

    You want to have two pages:

    One at http://example.com/something/slug/
    And another at: http://example.com/something/something-else/slug/

    Correct?

    Unfortunately it looks like this issue is still being worked on and is a lot more complicated than it seems. For now, I’m not sure of another way around it.

    Moderator bcworkz

    (@bcworkz)

    I would not recommend holding out for that Trac ticket being resolved. If I’m not mistaken, it will only allow duplicate slugs if they are for different post types. It sounds like you want duplicate slugs for the same page post_type, but having different content.

    What you could do I suppose is have the Europe pages all be one post type and all the Asia content be another. But you still need to hold out for the Trac ticket being resolved. If you notice the related dates, they are all quite old, no resolution can be expected soon.

    Your situation is the same that’s encountered by most multi-lingual sites. Consider solving it by using a multi-lingual plugin. For a general discussion of possible approaches, see Multilingual WordPress.

    Thank you for your reply.

    It seems that the most suitable solution is as @bcworkz said to make new post type for each continent, but the problem with us is that the content is already entered for all countries ( NOTE: Currently each post has a custom field to determine its continent ) which means that we have to switch the products of first post type to the second post type and custom taxonomy to the second taxonomy and this is really dangerous since we have also WPML language linking between the products which will be removed if we made any query.

    So please if you have any other solution for this, it will be really appreciated.

    Thanks in advance,

    Moderator bcworkz

    (@bcworkz)

    Maybe you could generate links that have the same slug for multiple posts, then adjust the slug internally to something unique. Say you have links like example.com/asia/my-post-slug/ and example.com/europe/my-post-slug/.

    Then in the “pre_get_posts” callback you rewrite the resulting query vars to the actual unique slug, either my-post-slug-as or my-post-slug-eu. Untested, but I don’t see why it wouldn’t work. You get the links you want and WP can maintain the unique slugs that it requires. When posts are created it’ll be important that slugs follow the prescribed format. This could be verified when the post is saved, appending the appropriate suffix as needed based on the custom field value.

    There is one drawback. I’m pretty sure WP will rewrite the browser URL into the default permalink once the proper post is returned. I not sure if this behavior can be prevented. I could be wrong about this. I suggest setting up a quick proof of concept test to see if this is a viable scheme or not.

    Our first solution was simply to add “-eu” and “-as” , but this will affect the SEO since we need to have same slug for the SEO.

    So it seems that currently there is no real solution for this?

    Moderator bcworkz

    (@bcworkz)

    I believe that as long as the canonical URL link tag is the same in both cases, the different slugs will not affect SEO. This can be managed through the “get_canonical_url” filter. Just strip off any trailing -as or -eu for this URL.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Create Duplicate Slugs for pages same page title but different content’ is closed to new replies.