Fetch first image URL from post and set as featured image URL

First, paste this function on your functions.php file. function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘//i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = “/images/default.jpg”; } return $first_img; } Once done, you can simply call the function within the loop to display the … Read more

How to add text & call to action button to featured image on homepage?

If your theme allow you to edit the text displayed on your home page, when you just need to add a a link. A click to call link is a simple HTML link, except that the value of the href attribute needs to refer to the “tel” protocol: <a href=”https://wordpress.stackexchange.com/questions/278772/tel:XXXXXXXXXXXXX”>Call Us</a> Where “XXXXXXXXXXXXX” is your … Read more

Display featured image metadata?

The featured image is just an attachment, and you can retrieve its post ID via get_post_thumbnail_id, e.g. $featured_image_id = get_post_thumbnail_id( $post ); At which point you’re dealing with a standard post of type attachment. Other than checking that there is a featured image, no special handling is needed and it can be treated as any … Read more