Skip to content

Instantly share code, notes, and snippets.

@csaborio001
Last active May 11, 2021 12:09
Show Gist options
  • Save csaborio001/5de273599302ba125d119d1f26936ef2 to your computer and use it in GitHub Desktop.
Save csaborio001/5de273599302ba125d119d1f26936ef2 to your computer and use it in GitHub Desktop.
Using Meow Gallery to Display ACF Galleries
// Need to set the shortcut parameter in the post template where the gallery will be displayed.
[meow-gallery acf=1]
// Hook up to intercept the gallery shortcode and check for attribute.
add_filter(
'shortcode_atts_gallery',
function( $result, $defaults, $atts ) {
if ( 1== $atts['acf']) { // The ACF gallery MUST be set to return IDs for this to work!
$gallery_id_array = get_field( 'gallery_event_gallery', get_the_ID() );
$ids = implode( ',', $gallery_id_array );
$result['ids'] = $ids;
}
return $result;
},
10,
3
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment