Update sub row() (ACF): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 25: Regel 25:
 
endwhile;
 
endwhile;
 
</pre>
 
</pre>
 +
 +
== Zie ook ==
 +
 +
* [[Update sub field() (ACF) | update_sub_field()]]

Versie van 1 aug 2022 11:08

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;

Zie ook