Insert sometext after first h3 in content

Note returning $content[0]; when !is_single() you’ll get non-exist errors.


You can accomplish what you’re after with somthing like:

add_filter('the_content', function ($content){
    if (!is_single()) return $content;
    $div = "🎅🏻";
    return preg_replace('/<\/h3>/i', "</h3>".$div, $content, 1);
});

note the third parameter of preg_replace() is the limit, setting to 1 will restrict the replace to the first match.