Editing <?php the_content(‘Read more…’); ?> olatechproMay 18, 20232 Views Is it possible to automatically add for example image before first h2 tag in the_content? Post Views: 2 Related postsGet rid of this Strict Standards warningWooCommerce: get_current_screen not working with multi languageCan’t login on WordPressForce HTTPS using .htaccess – stuck in redirect loopWordPress: Ajax not working to insert, query and result dataHow Can I pass an image file to wp_handle_upload?
Yes, it is possible. You can use the_content hook and assign your own filter to this hook. Then you should (that is the part when things get a little bit messy) parse and replace content of that post. So for example you can do it like so: function my_the_content_filter($content) { $content = str_replace('<h2 ', '<img src=""...><h2 ', $content); return $content; } add_filter( 'the_content', 'my_the_content_filter' );
Yes, it is possible.
You can use
the_content
hook and assign your own filter to this hook.Then you should (that is the part when things get a little bit messy) parse and replace content of that post.
So for example you can do it like so: