Actually, this plugin got the simple function I was looking for:
http://ww.wp.xz.cn/support/plugin/multiple-post-thumbnails
if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
You get it by setting it in functions.php:
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(
array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => 'post'
)
);
}
You can create as many Featured Images as you want.
DFI has a better interface functionality, with the “create featured images on the fly”, so it would be perfect if you could implement a simpler code to call a single image, in one line of code.
Hello gian-ava,
There is a function called get_nth_featured_image() available from ver. 3.0.0 .
Is it what you are looking for?
Thanks,
Ankit
Hi Ankit, thanks for the feedback.
I tried “get_nth_featured_image()” with different options, and nothing works:
get_nth_featured_image(2)
get_nth_featured_image(‘2’)
If one wants to call the “Featured Image 2” what is the complete code?
I honestly think that this is a bit of information that should be clear even before you install the plugin, from the plugin page, instead of digging and guessing for hours.
Just trying to give you my feedback as a user who’s struggling with what should take a few seconds.
Also, it could be nice for your plugin if you could change the “Featured Image 2”, “Featured Image 3”, with a custom name, as it could be more coherent with what the image is used for, like “Slider Image”, Thumbnail Image”, Post Image”. That could be a nice add on.
Hello gian-ava,
Did you tried passing the post id along with the position?
For example $nth_image = $dynamic_featured_image -> get_nth_featured_image( 3, 5 ); where 3 is the position of the featured image and 5 is the post id. So it will basically fetch the second featured image from the post with an id of 5.
And thanks for the feature request. Actually that feature is in the to-do list. Future version will allow users to add their custom title as the heading.
Thanks,
Ankit