I have not used ACF before but i suspect your post-2.php
lacks $post_id
as in have_rows($field_name, $post_id)
(see). If you are using ajax there is no way that your ajax function know the page you are on and what post you are seeking so you better use $post_id
to tell ajax function which post data you want.
Correct way of using ajax in wordpress
is directing ajax request to ajaxurl = admin_url().'admin-ajax.php'
. It is better to wp_localize_script
but can do like this <div id="part2" data-url="<?php echo admin_url().'admin-ajax.php'; ?>"></div>
and the ajaxurl = $('#part2').data('url);
You can use something like this
$.ajax({
url: ajaxurl,
cache: false,
type : 'post',
data : {
action: 'load_post_acf' // This will be used in hook
},
success: function(result){
$("#part2").html(result);
$('#loading-image').hide();
},
});
Ajax function for post-2.php
you can do something like ..
add_action('wp_ajax_nopriv_load_post_acf','your_ajax_function');
add_action('wp_ajax_load_post_acf','your_ajax_function');
function your_ajax_function(){
global $post;
if( have_rows('repeat_field',$post->ID) ):
// do something
else:
echo '<h4>No rows found.</h4>'; //do something else
endif;
}