get_row()

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 = true]);
  • $format_value (bool) (Optional) Whether to apply formatting logic. Defaults to true.

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.

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.