8. Référence des Fonctions de Ligne | Field Forge - Champs personnalisés, conçus pour la vitesse
Télécharger Se connecter

8. Référence des Fonctions de Ligne

Fonctions d’aide qui fournissent un contexte sur la ligne actuelle lors de l’itération.

get_row()

Retourne la ligne actuelle complète sous forme de tableau associatif.

Retourne : array — toutes les valeurs des sous-champs pour la ligne actuelle.
php
if ( have_rows( 'slides' ) ) :
    while ( have_rows( 'slides' ) ) : the_row();
        $row = get_row();
        // $row = ['title' => 'Slide 1', 'image' => 'url', ...]
    endwhile;
endif;

get_row_index()

Retourne l’index basé sur 1 de la ligne actuelle.

Retourne : int — numéro de ligne indexé à 1 (1, 2, 3, …).
php
if ( have_rows( 'features' ) ) :
    while ( have_rows( 'features' ) ) : the_row();
        $index = get_row_index();
        $delay = ( $index - 1 ) * 100;
        echo '<div class="feature feature-' . $index . '" style="animation-delay: ' . $delay . 'ms;">';
        echo '<span class="number">' . str_pad( $index, 2, '0', STR_PAD_LEFT ) . '</span>';
        the_sub_field( 'title' );
        echo '</div>';
    endwhile;
endif;

get_row_layout()

Retourne le nom de la mise en page pour la ligne actuelle dans un champ de Contenu Flexible.

Retourne : string — slug de mise en page (par exemple, 'hero', 'text_block', 'gallery').
php
if ( have_rows( 'page_sections' ) ) :
    while ( have_rows( 'page_sections' ) ) : the_row();
        $layout = get_row_layout(); // e.g., 'hero', 'text_block', 'gallery'
        get_template_part( 'sections/section', $layout );
    endwhile;
endif;

Référence Complète des Fonctions

FonctionSignatureRetourne
get_field()( $selector, $post_id = false )mixed\null
the_field()( $selector, $post_id = false )void
get_fields()( $post_id = false )array
get_field_object()( $selector, $post_id = false )array\false
get_field_objects()( $post_id = false )array
update_field()( $selector, $value, $post_id = false )int
delete_field()( $selector, $post_id = false )bool
have_rows()( $selector, $post_id = false )bool
the_row()()void
get_row()()array
get_row_index()()int (indexé à 1)
get_row_layout()()string
get_sub_field()( $selector )mixed
the_sub_field()( $selector )void
get_sub_field_object()( $selector )array\false
acf_register_block_type()( $config )void
fieldforge_register_block_type()( $config )void
fieldforge_add_options_page()( $args )void
fieldforge_preload()( $post_ids )void

Assistant IA Forge En ligne

Bonjour ! Je suis l'assistant IA Field Forge. Posez-moi n'importe quelle question sur le plugin — configuration, fonctionnalités, dépannage ou développement.

À l'instant
Propulsé par Forge IA · Parcourir la documentation