
Hi everyone,
The issues I am having are somewhat specific to my application, but here goes.
I am using ACF to generate flexible content fields that will allow a person to choose between one and two page column layouts on a page. I have also created a custom shortcode to display data that is stored in an ACF Options Page field.
When I add the custom shortcode to my one column layout, get_row_layout returns false.
Here is my code:
shortcode in functions.php
add_shortcode('map', 'map_func');
function map_func() {
ob_start();
if(have_rows('contact_method', 'options')) {
$values = get_field_object('contact_method', 'options')['value'];
foreach($values as $value) {
if($value['acf_fc_layout'] === 'address') {
$query = rawurlencode($value['contact_method_field']);
$src = 'https://www.google.com/maps/embed/v1/place?q=' . $query . '&key=XXXXXXXXXXXXXXXXXXXXXX';
?>
<iframe width="600" height="450" frameborder="0" style="border:0" src="<?php echo $src; ?>" allowfullscreen></iframe>
<?php }
}
}
$html = ob_get_contents();
ob_end_clean();
return $html;
}
page.php
<?php
if(get_row_layout() === 'one') { // returns false with custom shortcode added
echo $body;
}
if(get_row_layout() === 'two') { ?>
<div <?php echo $style_att_left; ?> class="col-md-6">
<?php the_sub_field('content_section_body_left'); ?>
</div>
<div <?php echo $style_att_right; ?> class="col-md-6">
<?php the_sub_field('content_section_body_right'); ?>
</div>
<?php }