Thanks for letting me know about this. I’ll look into it and get an update out with a fix.
Sorry for the long delay in seeing this issue… I didn’t realize that I wasn’t subscribed to notifications for this plugin (for a long time), so I had no idea of the support topics being created. I’ll be keeping up on things better now that I’m subscribed and am aware of these tickets.
Thread Starter
Julian
(@juliangk)
Hello @metaphorcreations,
thanks for the quick reply.
I reverted to using this filter:
/************* Fix Duplicate Post Polylang *****************/
if ( is_plugin_active('post-duplicator/m4c-postduplicator.php') ) {
add_action('mtphr_post_duplicator_created', function ($original_id, $duplicate_id, $settings) {
global $wpdb;
// Get term_taxonomy_id of the original-post's translations
$term_taxonomy_id = $wpdb->get_var($wpdb->prepare("
SELECT tr.term_taxonomy_id
FROM {$wpdb->prefix}term_relationships AS tr
JOIN {$wpdb->prefix}term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE tr.object_id=%s AND tt.taxonomy = \"post_translations\"
", $duplicate_id)) ?? false;
// Delete wp_term_relationships for duplicated post
if($term_taxonomy_id) {
$wpdb->delete("{$wpdb->prefix}term_relationships", [
'object_id' => $duplicate_id,
'term_taxonomy_id' => $term_taxonomy_id
]);
}
}, 10, 3);
}
But it would be very nice to have an option for this, within the plugin itself.
Best regards,
Julian
Is there any scenario where you’d want the connected posts to stay connected to the duplicate? I’m thinking not, but want to check.
So, I think I’ll just build in the updated functionality without having an option to keep those posts connected.
Thread Starter
Julian
(@juliangk)
Hi @metaphorcreations,
I can’t imagine a case in which it would be practically to have two posts connected to the same translation.
Sounds good, thanks for the info! I will get working on this and should have something out within the next week (possibly today if I can find time).
@juliangk I just released an update that should resolve this issue. Check it out and let me know how it works for you.
Thread Starter
Julian
(@juliangk)
Hello @metaphorcreations,
I know my reply is quite late but I just tested the plugin on another site and everything seems to work fine. Thank you for the update.
Best regards
Julian
No problem, thanks for confirming!