Skip to content Skip to sidebar Skip to footer

Isolating And Customizing First Image In Wordpress Post

I have a Wordpress site which uses a feature image on the posts which link to a page with the post's content (images, content, etc) I separate out the images from the content with

Solution 1:

Try This.

  preg_match_all('/<img[^>]+>/i',$get_the_content(), $result);
  echo"<pre>";
  print_r($result);

For Frist Image Try this $result[0][0].

It Get All Images.

Solution 2:

Try This.

$content = apply_filters ("the_content", $post->post_content);

    preg_match_all('/<img[^>]+>/i',$content, $result);

    echo"<pre>";

    print_r($result);

i hope this is useful for you.!

Post a Comment for "Isolating And Customizing First Image In Wordpress Post"