Update sub row() (ACF): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Nieuwe pagina aangemaakt met '<code>update_sub_row()</code>: Updates a row of data for an existing Repeater or Flexible Content sub field value. This function can be used inside or outside of a...') |
|||
(3 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 4: | Regel 4: | ||
Please note this function is used to modify a sub field value. To modify a parent field value, please use the <code>update_row()</code> function. | Please note this function is used to modify a sub field value. To modify a parent field value, please use the <code>update_row()</code> function. | ||
+ | |||
+ | ⇒ Lijkt niet goed te werken als het om alleen een subveld gaat c.q., een repeater met daarin maar 1 veld. | ||
== Syntaxis == | == Syntaxis == | ||
Regel 15: | Regel 17: | ||
* <code>$value</code> (required, array): The new row data. | * <code>$value</code> (required, array): The new row data. | ||
* <code>$post_id</code> (optional, mixed): The post ID where the value is saved. Defaults to the current post. | * <code>$post_id</code> (optional, mixed): The post ID where the value is saved. Defaults to the current post. | ||
+ | |||
+ | == Voorbeeld: Update binnen een have_rows()-loop == | ||
+ | |||
+ | <pre> | ||
+ | while (have_rows('add_code_to_head', 'option')): | ||
+ | update_sub_row('line', 1, "Niet zo lang" ); | ||
+ | endwhile; | ||
+ | </pre> | ||
+ | |||
+ | == Zie ook == | ||
+ | |||
+ | * [[ACF & PHP-API (WordPress) | ACF & PHP-API]] | ||
+ | * [[Update sub field() (ACF) | update_sub_field()]] |
Huidige versie van 1 aug 2022 om 11:13
update_sub_row()
: Updates a row of data for an existing Repeater or Flexible Content sub field value.
This function can be used inside or outside of a have_rows()
loop. When used inside, the current row will be used to update the sub field value. When used outside, the rows and parents must be specified to target the correct value place.
Please note this function is used to modify a sub field value. To modify a parent field value, please use the update_row()
function.
⇒ Lijkt niet goed te werken als het om alleen een subveld gaat c.q., een repeater met daarin maar 1 veld.
Syntaxis
update_sub_row($selector, $row, $value, [$post_id]) as boolean
$selector
(required, string|array): The sub field name or key, or an array of ancestors and row numbers.$row
(required, integer): The row number to update.$value
(required, array): The new row data.$post_id
(optional, mixed): The post ID where the value is saved. Defaults to the current post.
Voorbeeld: Update binnen een have_rows()-loop
while (have_rows('add_code_to_head', 'option')): update_sub_row('line', 1, "Niet zo lang" ); endwhile;