Support

Account

Home Forums ACF PRO How to get repeater field into a Sidebar widget?

Helping

How to get repeater field into a Sidebar widget?

  • Hi
    I can get a field and put it on every page with:
    <?php the_field('footer_link_box_text_1', 'option'); ?>

    Option seems to allow it to go on any page.

    I can get a repeated field with inputs from a specific page onto that page with:

    <?php $rows = get_field('package_name'); ?>
    		<?php if($rows) : ?>
    			<?php foreach($rows as $row) : ?>
                	<?php if($row['package_title']) : ?>
    					<div class="package">
    						<div class="package-title">
    							<h2><?php echo $row['package_title']; ?></h2>
    						</div>
    					</div>
                	<?php endif; ?>
    			<?php endforeach; ?>
    	<?php endif;  ?>

    But i can’t get a repeater field to go on every sidebar:

    <?php $rows = get_field('left_side_bar_content'); ?>
    		<?php if($rows) : ?>
    			<?php foreach($rows as $row) : ?>
                	<?php if($row['left_side_bar_description']) : ?>
    					<div class="package">
    						<?php echo $row['left_side_bar_description']; ?>
    					</div>
                	<?php endif; ?>
    			<?php endforeach; ?>
    	<?php endif;  ?>

    I think i need to get the ‘options’ type tag in there somehow??

    I did try [acf field="{$left_side_bar_content}"]
    but that didn’t work either?

    What am i doing wrong?

  • sorry, the answer was staring me in the face.
    i changed:
    <?php $rows = get_field('left_side_bar_content'); ?>
    to
    <?php $rows = get_field('left_side_bar_content', 'option'); ?>
    and it worked!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.