Reputation: 27
Maybe someone would be able to help me with the issue I have as I'm stuck with no ideas.
I have a shortcode on my site that is responsible for displaying photosets directly from Flickr (via external plugin).
The code generated by the plugin is the following: [justified_image_grid preset=c1 flickr_user=USERID flickr_photoset=PHOTOSETID]
My blog posts displays various photosets from Flickr. I'd like to avoid having to edit shortcode each and every time to update the shortcode code with the proper photoset ID so I decided to use custom field (Key = FlicktPhotoset, Value = Photoset ID) and add function to functions.php that would create my shortcode which would include original shortcode with the value from custom field.
Code in functions.php is the following:
function flickr_shortcode() {
echo do_shortcode('[justified_image_grid preset=c1 flickr_user=USERNAME flickr_photoset=PHOTOID]');
}
function flickr_shortcodes_init() {
add_shortcode('flickr', 'flickr_shortcode');
}
add_action('init', 'flickr_shortcodes_init');
What I'm stuck at is how to pass shortcode value into this code to automatically fetch PHOTOID from the custom field value.
Upvotes: 0
Views: 885
Reputation: 388
Something like this:
function flickr_shortcode() {
$FlicktPhotoset = get_post_custom_values("FlicktPhotoset");
echo do_shortcode('[justified_image_grid preset=c1 flickr_user=USERNAME flickr_photoset='.$FlicktPhotoset[0].']');
}
function flickr_shortcodes_init() {
add_shortcode('flickr', 'flickr_shortcode');
}
add_action('init', 'flickr_shortcodes_init');
Upvotes: 1