Looking to automatically separate the images and text from my wordpress post <?php the_content(); ?>
so I can put them in two different locations.
Not sure the best method to do this but have tried preg_replace approach but cant seem to figure out the right input
<?php
// get the content
$block = get_the_content();
// check and retrieve blockquote
if(preg_match ...
?>
It's answered here on wordpress.stackexchange.
$content = get_the_content();
$content = preg_replace("/<img[^>]+\>/i", " ", $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
To get the images from the inline post content this article will help.
preg_match('#(<img.*?>)#', $content, $results);
You need to build a new function with the_content() to filter media and string from post content.
To do it, You should to know php well.