• Resolved salem80

    (@salem80)


    This is my answer to the question I asked ~year ago, “Can you add [post custom fields] to the duplicated post”

    since I didn’t get the answer I forget about it, and because I’m not that expert on WP development I never tried to solve it myself.

    Anyway couple minutes ago I was able to solve my issue after asking ChatGPT how to inset costume meta key to a newly created post and here is the code (add it to your them function.php)

    function my_custom_function_after_insert_post($post_id, $post, $update) {
    if ( !$update ) {
    add_post_meta ( $post_id , 'mykey1', "" , true ) ;
    add_post_meta ( $post_id , 'mykey2', "" , true ) ;
    add_post_meta ( $post_id , 'mykey3', "" , true ) ;
    add_post_meta ( $post_id , 'mykey4' , "" , true ) ;
    }
    }
    add_action('wp_insert_post', 'my_custom_function_after_insert_post', 10, 3);

    • This topic was modified 11 months ago by salem80.
    • This topic was modified 11 months ago by salem80.
Viewing 1 replies (of 1 total)
  • Plugin Support MixHa

    (@mixha)

    Hello @salem80 ,

    Thank you for your feedback. Copying all custom meta data from posts is already supported with the premium version of the plugin.

    Kind regards

Viewing 1 replies (of 1 total)
  • The topic ‘here is how to add [post custom fields] to the duplicated post’ is closed to new replies.