Last active
May 11, 2021 12:09
-
-
Save csaborio001/5de273599302ba125d119d1f26936ef2 to your computer and use it in GitHub Desktop.
Using Meow Gallery to Display ACF Galleries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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