acf_loop::add_loop
add_loop
This function will add a new loop
Method of the class: acf_loop{}
No Hooks.
Returns
null. Nothing (null).
Usage
$acf_loop = new acf_loop(); $acf_loop->add_loop( $loop );
- $loop
- .
Default:array()
Changelog
| Since 5.3.2 | Introduced. |
acf_loop::add_loop() acf loop::add loop code ACF 6.0.4
function add_loop( $loop = array() ) {
// defaults
$loop = wp_parse_args(
$loop,
array(
'selector' => '',
'name' => '',
'value' => false,
'field' => false,
'i' => -1,
'post_id' => 0,
'key' => '',
)
);
// ensure array
$loop['value'] = acf_get_array( $loop['value'] );
// Re-index values if this loop starts from index 0.
// This allows ajax previews to work ($_POST data contains random unique array keys)
if ( $loop['i'] == -1 ) {
$loop['value'] = array_values( $loop['value'] );
}
// append
$this->loops[] = $loop;
// return
return $loop;
}