get_row()

Overview

This function will return an array containing all sub field values for the current row within a have_rows() loop.

Change Log

  • Added in version 5.3.3

Parameters

$row = get_row( $format_values );
  • $format_values (boolean) whether or not to format the value loaded from the db. Defaults to false (not required).

Usage

This example demonstrates how to use this function to get the current row and output sub field data. This is not the standard way to output sub field data (we advise using get_sub_field() and the_sub_field()), but it can be handy.

Note that the_row() also returns the current row array (and it also progresses through the loops).

<?php if( have_rows('slides') ): ?>

	<?php while( have_rows('slides') ): the_row(); 
		
		// vars
		$row = get_row();
		
		
		if( $row['image'] ): ?>
			
			<img src="<?php echo $row['image']; ?>" />
			<p><?php echo $row['caption']; ?></p>
			
		<?php endif; ?>

	<?php endwhile; ?>

<?php endif; ?>

 

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.