I have a Wordpress theme and I am trying to change how it outputs the post images. I am here is my code I am trying in functions.php add_filter( 'post_thumbnail_html', 'my_image_func', 10, 7); function my_image_func($html, $post_id ) { $url = wp_get_attachment_url($post_id); // Grab the current image URL $html = "<div style='background: url(\"$url\"); ></div>"; return $html; } PHP: But for some reason $url turns up empty Can anyone point me in the right direction on how to fix this?