Categories default images - Solution
Hi, this is my solution to add the default image for categories. Tested on WP 3.3.1 and CP 3.1.6
I installed the plugin, which automatically display a default Post Thumbnail image.
You can download it here http://wordpress.org/extend/plugins/...humbnail-plus/
Edit the plugin settings by visiting Settings -> Default Thumb Plus
Example of configuration:
2012-02-03 20h56_03.jpg
The plugin works great, but ClassiPress not give him a demonstrate it.
Need to modify the file \classipress\includes\theme-functions.php:
1. Ad loop thumbnails
function cp_ad_loop_thumbnail()
Find:
Code:
// no image so return the placeholder thumbnail
} else {
echo '<a href="'. get_permalink() .'" title="'. the_title_attribute('echo=0') .'"><img class="attachment-medium" alt="" title="" src="'. get_bloginfo('template_url') .'/images/no-thumb-75.jpg" /></a>';
}
Replace with:
Code:
// no image so return the placeholder thumbnail
} else {
echo '<a href="'. get_permalink() .'" title="'. the_title_attribute('echo=0') .'">';
// if category thumbnail is set
if ( get_the_post_thumbnail( $post->ID, 'ad-thumb' ) ) echo get_the_post_thumbnail( $post->ID, 'ad-thumb' );
// default ClassiPress thumbnail
else echo '<img class="attachment-medium" alt="" title="" src="'. get_bloginfo('template_url') .'/images/no-thumb-75.jpg" />';
echo '</a>';
}
2. Featured thumbnails
function cp_ad_featured_thumbnail()
Find:
Code:
// no image so return the placeholder thumbnail
} else {
echo '<a href="'. get_permalink() .'" title="'. the_title_attribute('echo=0') .'"><img class="attachment-sidebar-thumbnail" alt="" title="" src="'. get_bloginfo('template_url') .'/images/no-thumb-sm.jpg" /></a>';
}
Replace with:
Code:
// no image so return the placeholder thumbnail
} else {
echo '<a href="'. get_permalink() .'" title="'. the_title_attribute('echo=0') .'">';
// if category thumbnail is set
if ( get_the_post_thumbnail( $post->ID, 'sidebar-thumbnail' ) ) echo get_the_post_thumbnail( $post->ID, 'sidebar-thumbnail' );
// default ClassiPress thumbnail
else echo '<img class="attachment-sidebar-thumbnail" alt="" title="" src="'. get_bloginfo('template_url') .'/images/no-thumb-sm.jpg" />';
echo '</a>';
}
3. Single ad thumbnails
function cp_get_image_url()
Find:
Code:
// no image so return the placeholder thumbnail
} else {
echo '<img class="attachment-medium" alt="" title="" src="'. get_bloginfo('template_url') .'/images/no-thumb.jpg" />';
}
Replace with:
Code:
// no image so return the placeholder thumbnail
} else {
// if category thumbnail is set
if ( get_the_post_thumbnail( $post->ID, 'medium' ) ) echo get_the_post_thumbnail( $post->ID, 'medium' );
// default ClassiPress thumbnail
else echo '<img class="attachment-medium" alt="" title="" src="'. get_bloginfo('template_url') .'/images/no-thumb.jpg" />';
}
That's all
Do not forget to thank the author of the plugin 'Default Thumbnail Plus'!