I need to do custom RSS file, And i need to show only pictuer from post_content
and put it in <img>
tag and remove any word, from post_content
.
So how can i display only images from post_content
.
<?php foreach ($posts as $post) {
$content = get_the_content();
$postOutput = preg_replace('#<a[^>]+>([\r\n|\n]+)?<img[^>]+>([\r\n|\n]+)?<\/a>#','', $post->post_content);
//$postContent = preg_replace("/<a[^>]+\>/i", "", $postOutput);
?>
<article>
<id></id>
<title><?php echo get_the_title($post->ID); ?></title>
<link><?php echo get_permalink($post->ID); ?></link>
<abstract></abstract>
<body><?php echo '<![CDATA['.$postOutput.'<br/><br/>more: <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.']]>'; ?></body>
<date><?php yoast_rss_date( strtotime($post->post_date_gmt) ); ?></date>
<image_original>....</image_original>
<image_thumb>....</image_thumb>
<image_original_alt>....</image_original_alt>
<slideshow_images>
<image>
<image_url>.....</image_url>
<image_thumb_url>.....</image_thumb_url>
<image_alt>.....</image_alt>
</image>
<image>
<image_url>.....</image_url>
<image_thumb_url>.....</image_thumb_url>
<image_alt>.....</image_alt>
</image>
<image>
<image_url>.....</image_url>
<image_thumb_url>.....</image_thumb_url>
<image_alt>.....</image_alt>
</image>
</slideshow_images>
</article>
<?php } ?>