Displaying Flickr Images within or after the_content
-
First, thank you for continuing to support this GREAT plugin and older versions of WP – I do plan to update this particular site I’m using your plugin on, to at least WP ver 4.4.3 this summer (a few other plugins it uses are not yet compatible with 4.5).
However, I’m hoping you won’t mind a suggestion regarding the code you provide on the Installation tab here (for getting the contents of the set and looping through them) – I have put that in my functions.php file as a ‘shortcode’, then I call the shortcode on the page I want the set to display on.
BUT in order to get the shortcode to behave properly, which is to say that it should output it’s contents at the point in the page/post where it’s used (which could be before the content, midway through it, or after the content), I had to change the ‘echo’ to use ‘return’ instead…..otherwise the ‘echo’ is always output first on the page.
SO here’s what I used:
add_shortcode( 'flickrSets', 'display_flickrSets' ); function display_flickrSets() { $flickr_set = get_field('flickr_image_gallery'); //this is just what I named the Flickr image field if (isset($flickr_set['items'])) { foreach ($flickr_set['items'] as $id => $photos) { foreach ($photos as $photo) { $html.= '<a rel="lightbox" class="mediagallery" href="' . $photo['large'] . '" title="' . $photo['title'] . '"><img src="' . $photo['thumb'] . '" /></a>'; } } } return $html; }
Ideally I would like to display just the sets (albums) cover photo and name only, then clicking on each album cover would open that set in the overlay, but my coding skills are not up to par yet, it may take me a while to figure that out!
I hope this is helpful to anyone.
https://www.ads-software.com/plugins/flickr-field-for-advanced-custom-fields/
- The topic ‘Displaying Flickr Images within or after the_content’ is closed to new replies.