Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i'm using an rss to post plugin. The posts fetches from the RSS do not have any pictures associated with them. Is there a way to automatically assign a 'featured image' to posts from a category?

Another option is that in my WP theme, with the custom field as 'thumb' I can add images/reuse same images.. is there a way to make use of this and assign a default pic to all posts from a category?

Edit: Based on Martin's suggestion I installed the get image plugin. The code mentioned in the read me is this:

get_the_image( array( 'default_image' => 'http://www.mydomain.com/wp-content/uploads/defaultimage.png' ) );

However, my theme isn't that direct. It makes use of a function in the functions.php file.

// Get image attachment (sizes: thumbnail, medium, full)
function get_thumbnail($postid=0, $size='full') {
    if ($postid<1) 
    $postid = get_the_ID();
    $thumb_key = get_theme_mod('thumb_key');
    if($thumb_key)
        $thumb_key = $thumb_key;
    else
        $thumb_key = 'thumb';
    $thumb = get_post_meta($postid, $thumb_key, TRUE); // Declare the custom field for the image
    if ($thumb != null or $thumb != '') {
        return $thumb; 
    } elseif ($images = get_children(array(
        'post_parent' => $postid,
        'post_type' => 'attachment',
        'numberposts' => '1',
        'post_mime_type' => 'image', ))) {
        foreach($images as $image) {
            $thumbnail=wp_get_attachment_image_src($image->ID, $size);
            return $thumbnail[0]; 
        }
    } else {
        return get_bloginfo ( 'stylesheet_directory' ).'/images/default_thumb.gif';
    }

}

// Automatically display/resize thumbnail
function tj_thumbnail($width, $height) {
    echo '<a href="'.get_permalink($post->ID).'" rel="bookmark"><img src="'.get_bloginfo('template_url').'/timthumb.php?src='.get_thumbnail($post->ID, 'full').'&amp;h='.$height.'&amp;w='.$width.'&amp;zc=1" alt="'.get_the_title().'" /></a>';
}

I need help in adding the get_the_image function into the one above so it checks.. If category id=120, then display mydefaultimage.png else, do the regular thing.

Thanks.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

if i understand your question correctly then have a go with Justin Tadlocks get the image plugin, olden but golden and does the default image per category etc.

share|improve this answer
    
Thanks Martin, will give this plugin a test ride and see how it works out? –  Sledge81 May 21 '11 at 17:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.