Description
Returns an array containing all values (in the format name => value) for the current row within a have_rows()
loop.
Parameters
get_row([$format_value = false]);
$format_value
(bool) (Optional) Whether to apply formatting logic. Defaults to false.
Return
(array) Array of values in the format name => value.
Changelog
- Added in version 5.3.3
Example
This example demonstrates how to load the current row values and display them.
<?php if( have_rows('slides') ): ?>
<?php while( have_rows('slides') ): the_row();
// Get all values for this row.
$row = get_row();
// Check for image value.
if( $row['image'] ): ?>
<img src="<?php echo $row['image']; ?>" />
<p><?php echo $row['caption']; ?></p>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
Notes
Similarities to the_row()
This function returns the same data as the_row()
, however, it doesn’t step through the rows of a have_rows()
loop.
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.
Related
- Functions: have_rows()
- Functions: get_sub_field_object()
- Functions: get_row_index()
- Functions: the_sub_field()
- Deprecated: has_sub_field()