Have rows (ACF): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Nieuwe pagina aangemaakt met 'The function <code>have_rows</code> checks to see if a parent field (such as Repeater or Flexible Content) has any rows of data to loop over. This is a boolean func...') |
|||
Regel 13: | Regel 13: | ||
* <code>$selector</code>(string, required): Veldnaam of veldsleutel | * <code>$selector</code>(string, required): Veldnaam of veldsleutel | ||
* <code>$post_id</code> (mixed, optional): Post-ID. Voor items op pagina ''Options'', moet dit <code>option</code> zijn. | * <code>$post_id</code> (mixed, optional): Post-ID. Voor items op pagina ''Options'', moet dit <code>option</code> zijn. | ||
+ | |||
+ | == Voorbeeld: Heeft deze repeater subvelden? == | ||
+ | |||
+ | <pre> | ||
+ | if (have_rows('add_code_to_head', 'option')) | ||
+ | { | ||
+ | echo "It has rows!"; | ||
+ | } | ||
+ | </pre> |
Versie van 29 jul 2022 14:59
The function have_rows
checks to see if a parent field (such as Repeater or Flexible Content) has any rows of data to loop over. This is a boolean function, meaning it returns either true or false.
This function is intended to be used in conjunction with the_row()
to step through available values.
Using have_rows()
together with the_row()
is intended to feel native much like the have_posts()
and the_post()
WordPress functions.
Syntaxis
have_rows( $selector, [$post_id = false] ); as boolean - True if row exists
$selector
(string, required): Veldnaam of veldsleutel$post_id
(mixed, optional): Post-ID. Voor items op pagina Options, moet ditoption
zijn.
Voorbeeld: Heeft deze repeater subvelden?
if (have_rows('add_code_to_head', 'option')) { echo "It has rows!"; }