Home › Forums › General Issues › Use get_sub_field outside have_rows › Reply To: Use get_sub_field outside have_rows
Hey, here it is:
$content_blocks = get_field('content_blocks', $project->ID);
if( $content_blocks ):
foreach ($content_blocks as $key => $content_block):
$layout = $content_block['layout'];
$block_type = $classes[ $content_block['acf_fc_layout'] ];
$start = $content_block['start_at'];
$stop = $content_block['stop_at'];
if( $block_type == 'block__image' ):
$image = $content_block['image'];
$image_url = $image['sizes']['post-thumbnail'];
...
elseif( $block_type == 'block__video' ):
// Here is the problem... can't get the video the same way as with the image
$video = $content_block['video'];
// $video_url = get_sub_field('video', false, false);
...
endif;
endforeach;
endif;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
✨ You can now install ACF PRO with Composer, eliminating the need for third-party installers. Get the details and instructions here. https://t.co/ebEfp60Pwj
— Advanced Custom Fields (@wp_acf) February 2, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.