I am currently using the Multi Post Thumbnails plugin for WordPress, but I only want the extra thumbnails provided by the plugin to show on one specific page. The plugin does not appear to natively support this functionality but it seems like something that would be pretty easy to add, I’m just not sure of the right way to go about it as I’m fairly new to WordPress development.
The code for Multi Post Thumbnails is the following, which simply goes in functions.php:
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(
array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => 'page'
)
);
new MultiPostThumbnails(
array(
'label' => 'Tertiary Image',
'id' => 'tertiary-image',
'post_type' => 'page'
)
);
}
It seems to me it would just be a simple case of wrapping this in a check so that it only runs for a specific page ID, but I’m not quite sure how to go about doing that.
This is probably somewhat of a hack. To my knowledge post/page id’s are not accessible from inside
functions.php
.This is also probably a hack but it worked for me. I got stung by the AJAX ‘post_id’ back to the admin page once the image has been selected. My usage was for a slug but the function could easily be modified for a post ID.