Support » Plugin: Multisite Post Duplicator » How to copy the linked post without overwriting the title

  • Hi
    I would like to copy everything with the exception of post title. Is there a way not to copy/overwrite the title for the linked post?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author MagicStick

    (@magicstick)

    Should be straightforward. Add this code to your functions.php

    function dont_persist_title($persistpost){
    unset($persistpost[‘post_title’]);
    return $persistpost;
    }
    add_filter('mpd_setup_persist_destination_data',‘dont_persist_title’,10,1);

    Ive literally wrote this off-the-cuff so let me know how you get on.

    It didn’t work. The title is still being overwritten. Thank you for the ultra-quick response though. I wasn’t expecting that.

    Another question – is there a way to change the ID of the linked post to another ID? The way I have things set up it would be extremely helpful.

    Plugin Author MagicStick

    (@magicstick)

    Impossible to change the ID I’m afraid. Just the way WordPress/databases work.

    Can you try this code. It should work

    function dont_persist_title($persistpost){
    $new=$persistpost;
    unset($new[‘post_title’]);
    unset($new[‘post_name’]);
    return $new;
    }
    add_filter('mpd_setup_persist_destination_data',‘dont_persist_title’,10,1)
    • This reply was modified 5 years, 3 months ago by MagicStick.

    The code DID work! Thank you very much
    As for the ID, id it is already written in the database, I think I could perhaps edit the database with phpMyadmin and replace the ID. Does it make sense? The only problem is that I don’t know where to look exactly. Any ideas?

    Plugin Author MagicStick

    (@magicstick)

    If you edit the ids in phpmyadmin you will break the site. Guaranteed mate. I strongly recommend you stay away from that. Remember that ids are used to manage the relationship between posts, post meta, taxonomies, categories, permissions and god know what else on plugins you have! 🙂

    Fine, you’ve convinced me. And thanks for help.

    I looked at the plugin and I noticed that I can actually link to the existing post! so this solves my problem. I was excited and all and then I tried to execute the update on one of my posts and here’s what happened

    Warning: array_pop() expects parameter 1 to be array, null given in (…)/wp-content/themes/rehub/functions/review_functions.php on line 467

    Fatal error: Maximum execution time of 60 seconds exceeded in /(…)/wp-content/mu-plugins/wpengine-common/patterns.php on line 481

    Basically what I’m trying to achieve is to copy metadata from a post to its copy

    Thread Starter przyjem

    (@przyjem)

    Sorry, I take that last one back. It happened because I linked the post to itself. When I did it correctly – no errors! And the fields which could be copied got copied.

    Thread Starter przyjem

    (@przyjem)

    What would be the function that would prevent the plugin from copying the post content? I’d need only to copy custom fields.

    Thread Starter przyjem

    (@przyjem)

    Hi I noticed a bug with the code you sent me. While it works great when I copy to a new post it DOES NOT work if I copy to an old post (via MPD Create Link). In this last instance no data is copied – nothing at all.

    When I remove the code from functions.php it all gets back to normal – meaning I can copy the data via MPD Create Link. The only problem is that the title is copied over which we didn’t want.

    Any idea why the new code breaks Linked MPD Pages functionality?

    Thread Starter przyjem

    (@przyjem)

    Hi
    I would really appreciate if you could tell me how NOT to copy the title of a post AND be able to use MPD Create Link functionality at the same time

    Much appreciated!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How to copy the linked post without overwriting the title’ is closed to new replies.