Confused on Using Different Images on Categories
-
Hello!
A bit rusty with WordPress. Need some help with getting this snippet of code to work:
function dfi_category ( $dfi_id, $post_id ) { // all which have 'animals' as a category if ( has_category( 'animals', $post_id ) ) { //sub category if ( has_category( 'cats', $post_id ) ) { return 7; // cats img } else if has_category( 'dogs', $post_id ) { return 8; // dogs img } return 6; // default animals picture } return $dfi_id; // the original featured image id } add_filter( 'dfi_thumbnail_id', 'dfi_category', 10, 2 );
This is the code we have for the Use a different image for some categories, section of the FAQ. I’m trying to set multiple different images for different categories, so when I post something to Category A is pulls Image A. If I post something to category B, it pulls Image B. I understand the jist of what this code is doing, what I don’t understand is where specifically am I placing this code, is it the bottom of the functions page? And how am I linking the new images, am I listing out the URL of the image under return XYZ?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Confused on Using Different Images on Categories’ is closed to new replies.