Untitled
unknown
plain_text
2 years ago
427 B
6
Indexable
category.php <div class="margin-top-10 margin-bottom-10"> <?php $img = catch_that_image(get_the_ID()); if ($img) echo "<img src='$img'>"; ?> </div> functions.php function catch_that_image($post_id) { $post = get_post($post_id); preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = isset($matches[1][0]) ? $matches[1][0] : ''; return $first_img; }
Editor is loading...