• Resolved herculesnetwork

    (@herculesnetwork)


    
    function add_custom_field_automatically_two($post_ID) {
    global $post;
    $post_id = $post->ID;
    global $wpdb;
    //$my_customf = $post->post_title;
    //$my_customf = get_the_title( $post_id );
    $my_customf = "something string"; // worked, but I need post_title!       
    add_post_meta($post_ID, 'my_customf', $my_customf, true);
    }
    add_action('publish_page', 'add_custom_field_automatically_two');
    add_action('publish_post', 'add_custom_field_automatically_two');
    ?>
    

    Thanks ??

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to auto fill a custom_field with post_title value in wordpress post edit’ is closed to new replies.