Home › Forums › General Issues › Post object in Flexible Content › Reply To: Post object in Flexible Content
Hi John,
Thanks for your help
My problem was general PHP, I did PHP in PHP.
So I opened and closed correctly my php tag
Thank you for helping me on the fact that I used the code of the post_object like in the documentation here
Thank you for telling me that I could use the get_field simply
<div class="experiences">
<?php
// Check value exists.
if( have_rows('experiences') ):
echo '<h2 data-fontsize="24" data-lineheight="27">Expériences</h2><table class="listexp"><tr class="title"><td class ="date-in">Du</td><td class ="date-out">Au</td><td class ="agrement">Agrément du centre</td><td class ="adresse">Adresse</td><td class ="notif">Notification</td></tr>';
// Loop through rows.
while ( have_rows('experiences') ) : the_row();
// Case: Paragraph layout.
if( get_row_layout() == 'experience' ):
$du = get_sub_field('date_entree');
$au = get_sub_field('date_sortie');
$ctrlid = get_sub_field('agrement_du_centre');
$notif = get_sub_field('notification_ch_ctrl'); ?>
<?php echo '<tr><td class ="date-in">' . $du . '</td>' ?>
<?php echo '<td class ="date-out">' . $au . '</td>' ?>
<?php echo '<td class ="agrement">' ?>
<?php echo get_the_title( $ctrlid ); ?>
<?php echo '</td>' ?>
<?php echo '<td class ="adresse">' ?>
<?php the_field('cp_du_centre', $ctrlid); ?> <?php the_field('ville_du_centre', $ctrlid); ?>
<?php echo '</td>' ?>
<?php echo '<td class ="notif"><a href="' . $notif . '" target="_blank"><i class="fa fa-file-pdf-o"></i></a></td></tr>'; ?>
<?php endif;
endwhile;
echo '</table>';
else:
echo '<h2 data-fontsize="24" data-lineheight="27">Nombre de VTP par année</h2><p><i>Aucune valeur</i></p>';
endif; ?>
</div>
In the input form in wp_admin : $ctrlid is a post selector that returns the id of the selected post.
This code could be light, I would take the time to heal my code later
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.