Code, Themes

Responsive Featured Image function in WordPress themes

[UPDATE – May 23rd ’14]

I have included an update to this article which features new code and a downloadable plugin. Please note that this post simply shows a method I use to implement featured images into projects I am working on. If you attempt to use this method in your projects you could run into unforeseen issues. This is especially true if you are not familiar with developing in PHP or WordPress. I don’t recommend trying to implement this into your theme as such as it is not simply obtained by copy and paste. This article simply shows a method I use.

Continue Reading …

Code, Themes

Simple Featured Image Function for your WordPress theme!

Many times in theme development when we want to include a featured image we may just include the post thumbnail function like this example taken from the codex:

<?php 
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  the_post_thumbnail();
} 
?>
<?php the_content(); ?>

This may be fine. But what if you want to include the featured image in various places in your theme with different attributes such as image size? You could paste this function like this the_post_thumbnail('large'); but you also want to check if the post or page has a featured image in which you would paste the code above with the if statement has_post_thumbnail() as shown above.

Continue Reading …