Created
March 6, 2022 14:29
-
-
Save bradvin/9c68c708938ef628071443f061cb17f4 to your computer and use it in GitHub Desktop.
FooGallery Album - Get Previous & Next Gallery ID
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
echo 'Previous : ' . foogallery_album_find_previous_gallery_id( $current_foogallery_album, $foogallery->ID ); | |
echo 'Next : ' . foogallery_album_find_next_gallery_id( $current_foogallery_album, $foogallery->ID ); |
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
function foogallery_album_find_next_gallery_id( $album, $gallery_id ) { | |
$return = false; | |
foreach ( $album->galleries() as $gallery ) { | |
if ( $return ) { | |
return $gallery->ID; | |
} | |
if ( $gallery->ID === $gallery_id ) { | |
$return = true; | |
} | |
} | |
return null; | |
} | |
function foogallery_album_find_previous_gallery_id( $album, $gallery_id ) { | |
$previous_id = false; | |
foreach ( $album->galleries() as $gallery ) { | |
if ( $gallery->ID === $gallery_id ) { | |
return $previous_id; | |
} | |
$previous_id = $gallery->ID; | |
} | |
return $previous_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment