Last active
February 20, 2017 09:23
-
-
Save gregoirenoyelle/8c35f82d33ae7c724372 to your computer and use it in GitHub Desktop.
ACF PRO Repeater et Flexible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Template Name: Page avec Flexible | |
add_action( 'genesis_entry_content', 'gn_flexible_content', 50); | |
function gn_flexible_content() { | |
// Contrôle si le flexible a des champs | |
if( have_rows('flexible_content_field_name') ): | |
// boucle sur les champs du flexible | |
while ( have_rows('flexible_content_field_name') ) : the_row(); | |
if( get_row_layout() == 'paragraph' ): | |
the_sub_field('text'); | |
elseif( get_row_layout() == 'download' ): | |
$file = get_sub_field('file'); | |
endif; | |
endwhile; | |
else : | |
// pas de champs flexible | |
echo "pas de champ Flexible dans le coin !"; | |
endif; | |
} // function gn_flexible_content() | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Template Name: Page avec Repeater | |
add_action( 'genesis_entry_content', 'gn_repeater_content', 50); | |
function gn_repeater_content() { | |
// Contrôle si le repeater a des champs | |
if( have_rows('repeater_field_name') ): | |
// boucle sur les champs du repeater | |
while ( have_rows('repeater_field_name') ) : the_row(); | |
// affichage des sous-champs | |
the_sub_field('sub_field_name'); | |
endwhile; | |
else : | |
// pas de champs Repeater | |
echo "pas de champ Repeater dans le coin !"; | |
endif; | |
} // function gn_repeater_content() | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Page avec Flexible | |
*/ | |
get_header(); ?> | |
<div id="primary" class="content-area"> | |
<main id="main" class="site-main" role="main"> | |
<?php | |
// Contrôle si le flexible a des champs | |
if( have_rows('flexible_content_field_name') ): | |
// boucle sur les champs du flexible | |
while ( have_rows('flexible_content_field_name') ) : the_row(); | |
if( get_row_layout() == 'paragraph' ): | |
the_sub_field('text'); | |
elseif( get_row_layout() == 'download' ): | |
$file = get_sub_field('file'); | |
endif; | |
endwhile; | |
else : | |
// pas de champs flexible | |
echo "pas de champ Flexible dans le coin !"; | |
endif; | |
?> | |
</main><!-- .site-main --> | |
</div><!-- .content-area --> | |
<?php get_footer(); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Page avec Repeater | |
*/ | |
get_header(); ?> | |
<div id="primary" class="content-area"> | |
<main id="main" class="site-main" role="main"> | |
<?php | |
// Contrôle si le repeater a des champs | |
if( have_rows('repeater_field_name') ): | |
// boucle sur les champs du repeater | |
while ( have_rows('repeater_field_name') ) : the_row(); | |
// affichage des sous-champs | |
the_sub_field('sub_field_name'); | |
endwhile; | |
else : | |
// pas de champs Repeater | |
echo "pas de champ Repeater dans le coin !"; | |
endif; | |
?> | |
</main><!-- .site-main --> | |
</div><!-- .content-area --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment