Return to Snippet

Revision: 64833
at September 26, 2013 18:21 by FlashBuddy


Updated Code
// Add to functions.php theme support for Featured Images if your theme does not already include it.
if (function_exists('add_theme_support')) {
    add_theme_support('post-thumbnails');
    add_image_size('index-categories', 150, 150, true);
    add_image_size('page-single', 575, 200, true);
}

Call image using timthumb from a page or post by adding to page.php, single.php, home.php or index.php.

 <?php if (has_post_thumbnail( $post->ID )): ?>
   <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );  ?>
   <img class="featuredImage" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $image[0]; ?>&w=576&h=200&zc=1" alt="<?php the_title(); ?>" />
<?php endif; ?>

CSS
Note: image tag has the class .featuredImage. Style as needed:
img.featuredImage{border: 2px solid #ccc;padding: 10px;}

Revision: 64832
at September 25, 2013 03:14 by FlashBuddy


Updated Code
// Add to functions.php theme support for Featured Images if your theme does not already include it.
if (function_exists('add_theme_support')) {
    add_theme_support('post-thumbnails');
    add_image_size('index-categories', 150, 150, true);
    add_image_size('page-single', 575, 200, true);
}

Call image using timthumb from a page or post by adding to page.php, single.php, home.php or index.php.

 <?php if (has_post_thumbnail( $post->ID )): ?>
		      <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), �full� ); ?>
		      <img class="featuredImage" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $image[0]; ?>&w=576&h=200&zc=1" alt="<?php the_title(); ?>" />
<?php endif; ?>

CSS
Note: image tag has the class .featuredImage. Style as needed:
img.featuredImage{border: 2px solid #ccc;padding: 10px;}

Revision: 64831
at September 25, 2013 03:11 by FlashBuddy


Initial Code
// Add to functions.php theme support for Featured Images if your theme does not already include it.
if (function_exists('add_theme_support')) {
    add_theme_support('post-thumbnails');
    add_image_size('index-categories', 150, 150, true);
    add_image_size('page-single', 575, 200, true);
}

Call image using timthumb from a page or post by adding to page.php, single.php, home.php or index.php.

 <?php if (has_post_thumbnail( $post->ID )): ?>
		      <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ ); ?>
		      <img class="featuredImage" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $image[0]; ?>&w=576&h=200&zc=1" alt="<?php the_title(); ?>" />
<?php endif; ?>

Initial URL
https://hqsecure.com/grab-wordpress-featured-image-url/

Initial Description
I find myself needing to constantly find new ways to massage the featured image via WordPress themes. This is my starting code. Note: I often use timthumb.

Initial Title
WordPress Pull Featured Image with Permalink and CSS

Initial Tags
image

Initial Language
PHP