Using a for loop to register 10 featured images
-
This is an invaluable plugin! I am using it for a page which allows up to 10 featured images, and it’s all working a treat.
However it would be great to have a ‘for’ or a ‘foreach’ loop to register a large amount of featured images, as the code to register 10 new featured images becomes very long when repeated ten times. I have tried myself but can’t get it to work. I imagine it would have to be something similar to the following:
<?php if(class_exists('kdMultipleFeaturedImages')) { for ($i = 1; $i <= 10; $i++) { $args{$i} = array( 'id' => 'featured-image-{$i+1}', 'post_type' => 'page', // Set this to post or page 'labels' => array( 'name' => 'Featured image {$i+1}', 'set' => 'Set featured image {$i+1}', 'remove' => 'Remove featured image {$i+1}', 'use' => 'Use as featured image {$i+1}', ) ); new kdMultipleFeaturedImages( $args{$i} ); } } ?>
If anyone knows how to do this it would be really useful!
https://www.ads-software.com/extend/plugins/multiple-featured-images/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Using a for loop to register 10 featured images’ is closed to new replies.