5

My theme has a slider widget that allows the end user to select a category and it assigns the posts in that category to the slider. If a post has a featured image, its used as the background of the slide for that post.

However, there are cases where the featured image on the post itself needs to be different that the one used in the slider.

What are some options for a workaround?

Ideally, I'd like to just create a clone of the "Featured Image" panel, calling it "Slider Image". How difficult would that be?

What files do I need to clone? Any plugins that already do this?

2

This plugin has worked for me in the past:

http://wordpress.org/extend/plugins/multiple-post-thumbnails/

Or you could create a custom field - Advanced Custom Fields makes this very easy (and for the end user too):

http://plugins.elliotcondon.com/advanced-custom-fields/

This could be integrated by using the traditional 'featured image' as the slider image - ie leaving <?php the_post_thumbnail(); ?> or equivalent in the loop that makes your slider. Then when displaying the post, you could check if the post has a secondary image attached, and fall back to the featured image if not. Something like this with the Advanced Custom Fields Plugin (untested code):

<?php if (!( $secondary = get_field('secondary-image'))) {
    the_post_thumbnail(); // or however you like to do it
} else {
    echo wp_get_attachment_image($secondary);
} ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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