Okay so I have a custom post type called Multimedia Gallery. It's built using a repeater field that can take video, image, link, iframe, etc.
I'm using this plugin to insert these custom posts into blog posts, basically allowing me to insert my MM gallery into blog posts using a shortcode.
Problem is... the If and While statements seem to need a post ID to actually return the correct info. But I'm not quite sure to make that dynamic.
Here's my code:
<?php
/*
Template Name: Gallerys
*/
//Variables
$initialCardLoad = 5;
$loopLazyLoad = 0;
$gridPostID = get_the_ID();
?>
<section class="grid-content">
<div class="gridGallery">
<?php
// check if the repeater field has rows of data
if( have_rows('card', 355) ):
// loop through the rows of data
while ( have_rows('card', 355) ) : the_row();
$loopLazyLoad++; // iterate on loop each time you loop through
// display a sub field value inside a card
?>
<?php
//VARIABLES//
$title = get_sub_field('card_title');
$childImage = get_sub_field('card_picture');
$file = get_sub_field('card_video');
$video = $file['url'];
if($loopLazyLoad > $initialCardLoad):
if( $childImage ): ?>
<div class="grid-item">
<a data-fancybox="gallery" data-caption="<?php echo $title ?>" href="<?php
echo $childImage['url'];//big one here ?>">
<img class="lazy" data-src="<?php echo $childImage['url']; ?>">
</a>
<?php endif; ?>
<?php if( $video ): ?>
<div class="grid-item">
<video class="gallery-video lazy" loop autoplay muted>
<source src="<?php echo $video; ?>" type="video/mp4">
</video>
<?php endif; ?>
</div> <?php //end of grid item div
else : // Note the combination of the words.
if( $childImage ): ?>
<div class="grid-item">
<a data-fancybox="gallery" data-caption="<?php echo $title ?>" href="<?php
echo $childImage['url'];//big one here ?>">
<img class="" src="<?php echo $childImage['url']; ?>">
</a>
<?php endif; ?>
<?php if( $video ): ?>
<div class="grid-item">
<video class="gallery-video" loop autoplay muted>
<source src="<?php echo $video; ?>" type="video/mp4">
</video>
<?php endif; ?>
</div> <!-- end of grid item div -->
<?php endif; //end of initial card load of loop
endwhile; //end of while statement
The 355 is a manual insertion of the proper post ID for the purposes of testing if it would even work. It does! But how do I make it dynamic? When I try to use get_the_ID() it just gets the ID of the post I'm inserting into, rather than the one I'm inserting from.