Hello,
I am using this plugin. [[LINK href="null"]]https://wordpress.org/plugins/multiple-post-thumbnails/[[/LINK]]
Here is my code at the moment, which I have in functions.php and it works:
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => 'event-recurring'
) );
I need to use more than one post type here, but it is not possible to use an array for post_type, while using this plugin. So you have to loop through the custom post types and pass them to `post_type`
I am struggling to do this.
Someone on the wordpress support forum had exactly the same problem : https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-display-thumbnails-from-more-than-one-custom-post-type
I am looking for my code above to be modified, so that event-recurring and event (two different custom post types) work with the above code. I recommend checking out the link to the support forum as someone else has had exactly the same problem there.
So I am looking to loop through my two custom post types so that they work with the code above.
Kyle answers:
It says in the forum post there to run a foreach, so try something like this:
$postTypes = array( 'event-recurring', 'event-recurring-2', 'event-recurring-3' ); //Add your custom post types to this array
foreach( $postTypes as $postType ){
new MultiPostThumbnails(array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => $postType
));
}
timDesain Nanang answers:
alternative solutions, you can use:
1. [[LINK href="https://wordpress.org/plugins/advanced-custom-fields/"]]https://wordpress.org/plugins/advanced-custom-fields/[[/LINK]] plugin.
2. custom meta field, and I'll write the code for you.