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.

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?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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);
} ?>
share|improve this answer
add comment

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.