Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get acf repeater field

if( have_rows('rating_field') ):
  while ( have_rows('rating_field') ) : the_row();
    $title = the_sub_field('rating_title');
    $number = the_sub_field('rating_number');

    echo $title;
    echo $number;
  endwhile;
else :
endif;
Comment

repeater acf

<?php if( have_rows('slides') ): ?>
    <ul class="slides">
    <?php while( have_rows('slides') ): the_row(); 
        $image = get_sub_field('image');
        ?>
        <li>
            <?php echo wp_get_attachment_image( $image, 'full' ); ?>
            <p><?php the_sub_field('caption'); ?></p>
        </li>
    <?php endwhile; ?>
    </ul>
<?php endif; ?>
Comment

acf repeater

<?php if( have_rows('repeater_field_name') ): 
	while( have_rows('repeater_field_name') ): the_row(); 
		$image = get_sub_field('image');
	endwhile;
endif; ?>
Comment

acf repeater example count

$count = count(get_field('repeater_name'));
Comment

acf repeater

<?php if( have_rows('repeater_field_name') ): while ( have_rows('repeater_field_name') ) : the_row(); ?>
  <?php the_sub_field('sub_field_name'); ?>
<?php endwhile; else : endif; ?>
Comment

acf options repeater

<?php if( have_rows('repeater', 'option') ): ?>

    <ul>

    <?php while( have_rows('repeater', 'option') ): the_row(); ?>

        <li><?php the_sub_field('title'); ?></li>

    <?php endwhile; ?>

    </ul>

<?php endif; ?>
Comment

acf repeater

<?php 
$rows = get_field('repeater_field_name');
if( $rows ) {
    echo '<ul class="slides">';
    foreach( $rows as $row ) {
        $image = $row['image'];
        echo '<li>';
            echo wp_get_attachment_image( $image, 'full' );
            echo wpautop( $row['caption'] );
        echo '</li>';
    }
    echo '</ul>';
}
Comment

acf repeater

<?php 
if( have_rows('repeater_field_name') ) {
    while( have_rows('repeater_field_name') ) {
        the_row();
        $first_row_title = get_sub_field('title');
        // Do something...
        break;
    }
}
Comment

acf repeater

<?php
/**
 * Field Structure:
 *
 * - parent_repeater (Repeater)
 *   - parent_title (Text)
 *   - child_repeater (Repeater)
 *     - child_title (Text)
 */
if( have_rows('parent_repeater') ):
    while( have_rows('parent_repeater') ) : the_row();

        // Get parent value.
        $parent_title = get_sub_field('parent_title');

        // Loop over sub repeater rows.
        if( have_rows('child_repeater') ):
            while( have_rows('child_repeater') ) : the_row();

                // Get sub value.
                $child_title = get_sub_field('child_title');

            endwhile;
        endif;
    endwhile;
endif;
Comment

Acf Repeater setting check

add_filter('acf/load_field/name=my_field_name', 'my_acf_load_field');
function my_acf_load_field($field) {
  echo '<pre>'; print_r($field); echo '</pre>';
  return $field;
}
Comment

acf repeater

<?php
$rows = get_field('repeater_field_name' );
if( $rows ) {
    $first_row = $rows[0];
    $first_row_title = $first_row['title'];
    // Do something...
}
Comment

PREVIOUS NEXT
Code Example
Php :: iterate through an associative array php 
Php :: PHP money_format — Formats a number as a currency string 
Php :: $this- attribute laravel 
Php :: how to display image in wordpress 
Php :: phpcs ignore line warning 
Php :: replace php 
Php :: laravel model update 
Php :: how to get yesterday date in laravel 
Php :: laravel try catch example 
Php :: Composer Fatal error: Call to undefined function SymfonyPolyfillMbstringiconv() in phar 
Php :: run shell script from php file 
Php :: create a text file in laravel 
Php :: send email template via php 
Php :: php remove all whitespace from a string 
Php :: unset session key 
Php :: laravel file permissions 
Php :: if notexists in laravel query 
Php :: create seed file laravel 
Php :: random string generator php 
Php :: retrieving a cookie in php 
Php :: php sort by associative array value 
Php :: PHP OOP - Classes and Objects 
Php :: validation error laravel 8 with custom massage 
Php :: foreach in php 
Php :: php hello world 
Php :: Fibonacci Series Program. in php 
Php :: laravel sluggable 
Php :: PHP Forms - Required Fields 
Php :: laravel list of tables 
Php :: sha256 encryption in php 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =