Please bear with me because I am new to utilizing Wordpress PHP this way. I have the following script:
<div id="content">
<?php
// check if the repeater field has rows of data
if( have_rows('repeat_field') ):
$i = 0;
// loop through the rows of data
while ( have_rows('repeat_field') ) : the_row();
$i++;
// display a sub field value
if (!empty(get_sub_field('feature_image_post'))) {
echo '<a href="';
the_sub_field('restaurant_article_link');
echo '">';
}
if( $i >= 78 ) {
break;
}
endwhile;
else :
// no rows found
endif;
?>
</div>
<div id="loading-image" style="display: none;"></div>
<div id="part2"></div>
<script>
var w = $(window);
window.onscroll = function(ev) {
if ($(document).height() - w.height() == w.scrollTop()) {
$('#loading-image').show();
$.ajax({
url: "<?php echo get_stylesheet_directory_uri();?>/post-2.php",
cache: false,
success: function(result){
$("#part2").html(result);
},
complete: function(){
$('#loading-image').hide();
}
});
}
};
</script>
The the Php page that I am trying to load pretty much contains the same code . It just stops after loading 200 fields.
<?php
// check if the repeater field has rows of data
if( have_rows('repeat_field') ):
$i = 0;
// loop through the rows of data
while ( have_rows('repeat_field') ) : the_row();
$i++;
// display a sub field value
if (!empty(get_sub_field('feature_image_post'))) {
echo '<a href="';
the_sub_field('restaurant_article_link');
echo '">';
}
if( $i >= 200 ){
break;
}
endwhile;
else :
// no rows found
endif;
?>
I don't know why the php page (post-2.php) is not loading. The strange thing is that when I replace <?php echo get_stylesheet_directory_uri();?>/post-2.php
with a test html page <?php echo get_stylesheet_directory_uri();?>/test.html
The test page (test.html) loads.
I have to say that I looked on in my console using the console tab of my browser added console.log();
to view any errors and I'm not getting any errors. I also looked in my networked tag to ensure that post-2.php loaded properly and I'm not getting errors. My goal is to find out why my PHP page isn't loading
***** Update *****
I'm being told to use $post_id but I've never used it. Does anyone have a working example of this? Would it be similar to if( have_rows('repeat_field', $post_id) ):
or if( have_rows('repeat_field', 55612) ):
?