reset_rows

The Advanced Custom Fields reset rows function.

Description

reset_rows( (bool) $hard_reset = false ); 

This function will find the current loop and unset it from the global array. To bo used when loop finishes or a break is used

Parameters (1)

0. $hard_reset — Optional. (bool) => false
The hard reset.

Usage

  1. if ( !function_exists( 'reset_rows' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'advanced-custom-fields/core/api.php'; 
  3.  
  4. // The hard reset. 
  5. $hard_reset = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = reset_rows($hard_reset); 
  9.  

Defined (1)

The function is defined in the following location(s).

/core/api.php  
  1. function reset_rows( $hard_reset = false ) { 
  2.  
  3. // completely destroy? 
  4. if( $hard_reset ) 
  5. $GLOBALS['acf_field'] = array(); 
  6. else 
  7. // vars 
  8. $depth = count( $GLOBALS['acf_field'] ) - 1; 
  9.  
  10.  
  11. // remove 
  12. unset( $GLOBALS['acf_field'][$depth] ); 
  13.  
  14.  
  15. // refresh index 
  16. $GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']); 
  17.  
  18.  
  19. // return 
  20. return true; 
  21.  
  22.