Works great with a little code
-
I got the free version working perfectly last night with WordPress 5.7.
The description says the plugin will “add any number of featured images … without writing a single line of code”, which is a bit misleading. The plugin provides a GUI interface to flag images as featured, but to actually have the images appear on your site you need to write some code.
Stack Overflow to the rescue. I found this snippet there and got it working:
if( class_exists('Dynamic_Featured_Image') ) { global $dynamic_featured_image; $featured_images = $dynamic_featured_image->get_featured_images( ); //print_r($featured_images); //You can now loop through the image to display them as required foreach($featured_images as $featured_image) { echo "<img src='".$featured_image['full']."'>"; } }
Detailed instructions for those who, like me, don’t know PHP at all:
- Go to Appearance/Theme Editor
- Double click on the part of the site you want to add featured images. This will probably be ‘Single Page’ or ‘Single Post’, but it could be ‘Theme Header’, ‘Theme Footer’, or whatever.
- For most pages, you’ll want to paste the above code into ‘the loop’. If you don’t know what ‘the loop’ is, it’s worth looking in to, as it’s probably a bit different on different themes. On most themes, pasting the code anywhere between
while (have_posts()): the_post();
andendwhile;
should work. But where you put it in relation to other things in ‘the loop’ probably matters. - Note that everything between the quotes, after the word ‘echo’ in the code above is what will appear on your page. So any other stuff you want to add (list items, div tags, etc.) needs to go in there.
- If you’re adding any attributes, use single quotes or your whole site will bork.
- Have fun!
Hope that helps. And thank you, Ankit, for a great plugin!
- The topic ‘Works great with a little code’ is closed to new replies.