Sunday, June 19, 2011

post without image

place this code in functions.php in your theme folder.
<?php
function post_without_image($content) {
    ob_start();
    echo $content;
    $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents());
    ob_end_clean();
    return $postOutput;
}
?>


use post_without_image() function with 1 parameter with your content anywhere you want

<?php echo post_without_image($content); ?>

Instead of $content we use content variable where we store our content section. That's done.

No comments:

Post a Comment