• Resolved Henk Barreveld

    (@henk-barreveld)


    Hello,

    I use the Yoast Duplicate Post plugin on a site where editors publish new posts by cloning earlier posts: new information about the same subject, with the same post layout and even, partly, the same post contents. People do this by taking the most recent post about that subject, cloning it and then editing and publishing the clone.

    The site uses “pretty permalinks”, so the page/post URLs are like https://this.site/some-post/. Obviously an original post and its clones need to have different permalinks. Yoast Duplicate Post does not offer a feature to rename the permalink when it creates a clone (correct?) but leaves that to WordPress core. Unfortunately this results in…

    • original post: https://this.site/some-post/
    • clone: https://this.site/some-post-2/
    • clone of clone: https://this.site/some-post-2-2/
    • clone of clone of clone: https://this.site/some-post-2-2-2/
    • etc.

    I have seen URLs ending with -2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2-2/.

    This is not nice – and definitely undesirable from an SEO point of view, I guess.

    So I put a few lines of code in my theme’s functions.php file to deal with this, using the dp_duplicate_post hook from your developer documentation, producing:

    • original post: https://this.site/some-post/
    • clone: https://this.site/some-post-2/
    • clone of clone: https://this.site/some-post-3/
    • clone of clone of clone: https://this.site/some-post-4/
    • etc.

    Of course it would be much nicer if your plugin would handle this itself.

    Best regards!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi. Would it be possible to get the code that you created to do that. Thanks, Brian

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi @henk-barreveld

    We understand you have a concern with the permalinks when cloning posts and pages. We’re not exactly familiar with your site setup but on a default setup, when cloning a post and not changing the slug, it adds the /-2/ at the end of the URL.

    But when we clone that post again and don’t change the slug, it seems to add the /-3/ at the end of the URL instead of /-2-2/ as what you’ve encountered.

    Thread Starter Henk Barreveld

    (@henk-barreveld)

    Hello @mikes41720,

    Sorry, but I think you are mistaken.

    This is what WordPress does when YDP clones a post:

    • original post: https://my-site/some-post/
    • clone of original post: https://my-site/some-post-2/
    • another clone of original post: https://my-site/some-post-3/

    That’s also what you write – but that is not what I wrote about.

    People want to clone the most recent clone instead of the original post, for example because it is the easiest one to find, because it contains the latest version of the desired layout and fixed content parts, etc. If you ‘daisy-chain’ the clones, so to say, WordPress produces URLs ending with -2, -2-2, -2-2-2, etc.

    Please have another look.

    Best regards,
    Henk

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi @henk-barreveld

    Could you test this out on a setup with a default WP theme (e.g. TwentyTwenty) and only the Yoast Duplicate Post plugin so as to ensure there aren’t any conflicts from other plugins or themes that could modify the slugs?

    I tested this out by publishing a post (e.g. with a slug of /test/). Then I cloned that post and published it, and it had the slug of /test-2/. Then I cloned the clone (not the original post) and then published it, and it had the slug of /test-3/. So just to clarify, I did ‘clone’ the clone and not the original post.

    Thread Starter Henk Barreveld

    (@henk-barreveld)

    Hello @mikes41720,

    Thanks again. Problem solved – my bad…

    • I set up a new, empty site, theme Twenty Twenty-Two, only YDP plugin ad found that cloning clones produces slugs as desired, e.g. test, test-2, test-3, etc.
    • I set up a copy of my problem site, disabled all plugins except YDP and selected theme Twenty Twenty-Two: wrong result (slugs test, test-2, test-2-2, …).
    • Then I compared the YDP settings on both installations, and found that on the problem site the setting “Duplicate Post > What to copy > Slug” was checked. After unchecking this, the desired slugs test, test-2, test-3,… are produced.

    So the solution is to make sure that copying of the page/post slug is not set. Obvious, when you think about it.

    Thank you for your help!

    Best regards,
    Henk

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Ugly permalinks’ is closed to new replies.