Add div before the first paragraph the_content [closed]

Yogenisia’s is right that you should use the_content filter.

If you want to insert something before the first paragraph, locate the first <p> in $content, then insert your div with substr_replace.

add_filter( 'the_content', 'namespace_insert_before_first_paragraph' );

function namespace_insert_before_first_paragraph( $content ) { 
    $my_div = '<div> ... </div>';
    $first_para_pos = strpos( $content, '<p' );
    $new_content = substr_replace( $content, $my_div, $first_para_pos, 0 );

    return $new_content;
}

Keep in mind however that many embeds, such as Twitter’s, wrap their content in a <p>...</p>.