Ask your WordPress questions! Pay money and get answers fast! (more info)

Use more than 1 custom post type with multi post thumbnail plugin


I am using this plugin. [[LINK href="null"]][[/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 :

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.

Answers (2)


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=""]][[/LINK]] plugin.
2. custom meta field, and I'll write the code for you.