Support » Plugin: Dynamic Featured Image » Is there an example code to display a specific image?

  • Resolved gian-ava



    I am trying to use the plugin but without advanced PHP knowledge, there is no way to simply past a function and change the number to display a specific featured image.

    I have read this post:

    But that is so much code just to display one of the images.

    I was hoping that with the plugin something simple like this would be provided:
    if( class_exists(‘Dynamic_Featured_Image’) ) { $image[2] }

    …or something.

    That doesn’t seem the case, and even thought you provide a code with a returned arrey, there is no one single example to copy/paste and just change a number (1, for image 1; 2 for image 2; …).

    Am I missing something?

    Any help is highly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Actually, this plugin got the simple function I was looking for:

    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(
                    '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.

    Plugin Author Ankit Pokhrel


    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?


    Hi Ankit, thanks for the feedback.

    I tried “get_nth_featured_image()” with different options, and nothing works:


    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.

    Plugin Author Ankit Pokhrel


    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.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Is there an example code to display a specific image?’ is closed to new replies.