Automatically appending post title into post content upon publishing of post?

Please tell me, how can I fetch the post title and append it into the content of that post when I click the publish button?

Thank you!

Related posts

Leave a Reply

2 comments

  1. The wp_insert_post_data filter allows you to manipulate the post data before it is inserted in the database:

    function so16876611_insert_post_data( $data , $postarr )
    {
        $data['post_content'] = $data['post_content'] . $data['post_title'];
        return $data;
    }
    add_filter( 'wp_insert_post_data', 'so16876611_insert_post_data', 99, 2 );
    
  2. You would need to access save_post hook that’s being triggered after creating/updating page. It would look something like below:

    function custom_save_post($post_id) 
    {
        $_POST['content']=  $_POST['post_name'].$_POST['content']; 
    }
    add_action("save_post", "custom_save_post");