Easy Code for Featured Images in WordPress

Services: Law Firm Website Design . SEO . Internet Marketing . Law Firm Marketing Guide . Content Marketing . PPC

Below is a really easy code sample for utilizing featured images in WordPress.


To implement this you would basically just copy and paste the code snippet (found in text format below) where you want to utilize the featured image section in WordPress and the $featured_image variable would return the URL of the featured image.  The ‘else’ part of the statement sets a fallback (default) photo if a featured image is not chosen for a specific page.

Simple, but nice.




if(has_post_thumbnail()) { // check if the post has a Featured Image.

$photo = get_the_post_thumbnail();

$featured_image = explode(‘”‘, $photo);

$featured_image = $featured_image[‘1’];

} else {

$featured_image = ‘/wp-content/themes/paperstreet/images/default.jpg’;



Related Posts

Ready to Take Your Website to the Next Level? Great Ideas & Results Only a Phone Call Away

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Let's get started.

Leave a Reply

Your email address will not be published. Required fields are marked *