Home › Forums › Add-ons › Repeater Field › My code doesn't work › Reply To: My code doesn't work
I just took a quick look at the theme, since for a change I could actually look at a themes code. The answer is, no, the theme does not use standard WP functions to include template files. What this means is that the standard global variables (like $post
) are not available.
I think you can correct this by simply declaring the global variables that you need to access, in this case $post
<?php if(have_rows('otros_archivos')):
global $post; // add this
while (have_rows('otros_archivos')) : the_row();
$post_object = get_sub_field('antecedente');
echo "<ol>";
if($post_object):
$post = $post_object; setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php wp_reset_postdata();
else:
echo "<li>No se ha incluido ningún antecedente aún.</li><br/>";
endif;
echo "</ol>";
endwhile;
endif; ?>
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.