Created
May 4, 2020 08:08
-
-
Save gaambo/410003ba9127171dc1b3e7adf9122aeb to your computer and use it in GitHub Desktop.
Duplicate Elementor Templates with Duplicate Post Plugin (WordPress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// when duplicating a elementor template elementor save_post hook get's fired before all the post meta is duplicated | |
// and elementor sets the template type to the default page --> popups cannot be dupliated | |
// so the elementor key is removed from duplicating and duplicatd manually later on | |
add_filter('duplicate_post_meta_keys_filter', function ($keys) { | |
if ($k = array_search('_elementor_template_type', $keys)) { | |
array_splice($keys, $k, 1); | |
} | |
return $keys; | |
}); | |
add_action('dp_duplicate_post', function ($newPostId, $originalPost) { | |
$elementorTemplateType = get_post_meta($originalPost->ID, '_elementor_template_type', true); | |
update_post_meta($newPostId, '_elementor_template_type', $elementorTemplateType); | |
}, 11, 2); // prio 11 after duplicating |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment