Have rows (ACF): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
 
Regel 22: Regel 22:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
== Bronnen ==
 +
 +
* https://www.advancedcustomfields.com/resources/have_rows/

Huidige versie van 29 jul 2022 om 15:00

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 dit option zijn.

Voorbeeld: Heeft deze repeater subvelden?

if (have_rows('add_code_to_head', 'option'))
{
	echo "It has rows!";
}

Bronnen