Start Your Domain Search

Markit Media Blog

Adding Featured Image Support to Your WordPress Theme

At Markit Media, we believe people are visual creatures. In fact, we make our living beatifying custom WordPress blogs. And what good is a professional blog without photos? Therefore, our WordPress tutorial for today will be adding featured image support to your soon to be custom WordPress theme.

Step 1) Open up your preferred FTP client and code editor.

Step 2) Navigate to your theme directory. Locate your functions.php, style.css and index.php (or loop.php)

Step 3) In your functions.php, paste the following code:

/** Tell WordPress to run my_theme_setup() when the 'after_setup_theme' hook is run. */
add_action'after_setup_theme''my_theme_setup' );
if ( ! 
function_exists'my_theme_setup' ) ):
my_theme_setup() {
// add featured image support
add_theme_support'post-thumbnails' );

Step 4) Paste the following code into your index.php (or loop.php):

<!-- display featured images -->
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

Step 5) Paste the following code into your stylesheet(style.css) and style to match you theme:

/* ==== featured image ==== */ 
.attachment-post-thumbnail { 
margin-right: 10px;
margin-bottom: 10px;

Step 6) Pat yourself on the back for a job well done!

Be Sociable, Share!
Posted in Tips & Tricks, WordPress | Tagged , , |
Be Sociable, Share!