I worked around this calling posts with ajax from an api of posts and custom fields.
That also result in a empty space.
Yes, i double checked and the field and named right and they haven content.
Notice that if i use <?php print_r(have_rows('attachment_field', $post->ID)) ?>
is not working when i call the post content with ajax but if check the post directly in the url it works and displays “1”.
Nothing, just empty space.
Yes, it works. This show my post id, for example:
id="entry-3453"
Yes, i`ve declared this into a function in functions.php, this is my entire code:
function asset_empty_indexes(){
$post = get_post($_POST['post_id']);
<?php // My post ID displays ?>
<div class="hentry post" id="entry-<?php echo $post->ID; ?>">
<?php // My post title displays ?>
<?php echo apply_filters('the_title', $post->post_title) ?>
<?php // My post content displays ?>
<?php echo apply_filters('the_content', $post->post_content); ?>
<?php // My basic field displays ?>
<?php
$value = get_field( "prueba", $post->ID );
echo $value;
?>
<?php // But my repeater field does not displays ?>
<?php if( have_rows('attachment_field', $post->ID) ): ?>
<ul>
<?php while( have_rows('attachment_field', $post->ID) ): the_row();
$valueField = get_sub_field('attachment_name' );
?>
<li>
<p><?php echo $valueField; ?> </p>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div>
}
I´m, using it this way because i call this function with ajax to insert it in a wordpress post, all my fields show except repeater field.
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.