{"id":14299330,"date":"2021-04-09T16:51:45","date_gmt":"2021-04-09T16:51:45","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/works-great-with-a-little-code\/"},"modified":"2021-04-09T19:15:39","modified_gmt":"2021-04-09T19:15:39","slug":"works-great-with-a-little-code","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/works-great-with-a-little-code\/","title":{"rendered":"Works great with a little code"},"content":{"rendered":"<p>I got the free version working perfectly last night with WordPress 5.7.<\/p>\n<p>The description says the plugin will &#8220;add any number of featured images &#8230; without writing a single line of code&#8221;, 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. <\/p>\n<p>Stack Overflow to the rescue. I found this snippet there and got it working:<\/p>\n<pre><code> if( class_exists(&#039;Dynamic_Featured_Image&#039;) ) {\n    global $dynamic_featured_image;\n\n    $featured_images = $dynamic_featured_image-&gt;get_featured_images( );\n    \/\/print_r($featured_images);\n\n    \/\/You can now loop through the image to display them as required\n    foreach($featured_images as $featured_image) {\n        echo &quot;&lt;img src=&#039;&quot;.$featured_image[&#039;full&#039;].&quot;&#039;&gt;&quot;;\n    }\n\n }<\/code><\/pre>\n<p>Detailed instructions for those who, like me, don&#8217;t know PHP at all:<\/p>\n<ol>\n<li>Go to Appearance\/Theme Editor<\/li>\n<li>Double click on the part of the site you want to add featured images. This will probably be &#8216;Single Page&#8217; or &#8216;Single Post&#8217;, but it could be &#8216;Theme Header&#8217;, &#8216;Theme Footer&#8217;, or whatever.<\/li>\n<li>For most pages, you&#8217;ll want to paste the above code into &#8216;the loop&#8217;. If you don&#8217;t know what &#8216;the loop&#8217; is, it&#8217;s worth looking in to, as it&#8217;s probably a bit different on different themes. On most themes, pasting the code anywhere between <code>while (have_posts()): the_post();<\/code> and <code>endwhile;<\/code> should work. But where you put it in relation to other things in &#8216;the loop&#8217; probably matters.<\/li>\n<li>Note that everything between the quotes, after the word &#8216;echo&#8217; 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. <\/li>\n<li>If you&#8217;re adding any attributes, use single quotes or your whole site will bork.<\/li>\n<li>Have fun!<\/li>\n<\/ol>\n<p>Hope that helps. And thank you, Ankit, for a great plugin!<\/p>\n","protected":false},"template":"","class_list":["post-14299330","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/14299330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":3,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/14299330\/revisions"}],"predecessor-version":[{"id":14299904,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/14299330\/revisions\/14299904"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=14299330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}