Have rows (ACF): verschil tussen versies

Uit De Vliegende Brigade
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...')
 
 
(Een tussenliggende versie door dezelfde gebruiker niet weergegeven)
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>
 +
 +
== 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