0

I have created a custom post type with the ability to have multiple featured images. However, it would be nice if i didn't have 10 empty boxes on the post page asking for images... I would like a featured image box to appear if the previous one has been populated..

So, if the featured image is set, then the Image #2 box will appear, and so on..

That way things will be less cluttered. I am not sure if this is possible, any help would be appreciated.

I've tried:

if( $custom_meta_id['feature-image-3'] !== '') {

       new MultiPostThumbnails(array(
        'label' => '4th Image',
        'id' => 'feature-image-4',
        'post_type' => 'listing'
        )
    );

}
4
  • What is MultiPostThumbnails? Yes, you can do that but I don't know that I can guess at the correct code based on the information provided. There seems to be a lot of missing detail. – s_ha_dum Aug 25 '13 at 4:07
  • Also, the code posted is broken. You have a spurious single quote on the first line. Is that how you have it in your actual code or is that a typo when you posted here? – s_ha_dum Aug 25 '13 at 4:14
  • That is just a type here.. MultiPostThumbnails allows for multiple featured image boxes on my custom post type.. This is working perfectly.. I just want to only display one box, when it is populated the next box appears, etc.. – user32829 Aug 25 '13 at 13:29
  • It is possible to edit your question to fix the typo (I already did that for you). – s_ha_dum Aug 25 '13 at 14:46
0

This more of a PHP + Logic question than a WordPress one but I think the solution is pretty simple.

  1. Loop through some code to generate the existing boxes or the boxes with existing values
  2. And always print one empty box for a new image.

For example:

foreach ($my_existing_boxes as $k => $v) {
  // not sure how your code works exactly
}
new MultiPostThumbnails(
  array(
    'label' => 'New Image',
    'id' => 'feature-image-new',
    'post_type' => 'listing'
  )
);

Your Answer

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