Hi @christophvh,
Not really sure what the issue would be here. Your template looks pretty close to the example.
It seems like maybe the extension is not getting the current post id for some reason.
Any chance you can share a link?
hi @dcooney ,
I had the same idea, so i tried adding global $post to the template and did a var_dump($post->ID), This did nothing when acf was set to true. When i removed the acf tag from the shortcode, the dump showed the correct post id again.
I can’t provide you with a link because it is currently on localhost
Ok, no problem.
If you inspect the browser console, look for the .alm-listing div and let me know if the correct post ID is being passed in the data-acf-post-id parameter.
This is the full dump of the load-more div
<div id="ajax-load-more" class="ajax-load-more-wrap default alm-0 alm-loading" data-id="single-collaboration" data-alm-id="0" data-canonical-url="http://detekstsmederij.dev/samenwerkingen/nienke-peter/" data-slug="nienke-peter" data-post-id="202"><div class="alm-listing alm-ajax " data-acf="true" data-acf-field-type="flexible" data-acf-field-name="update_type" data-acf-post-id="202" data-repeater="template_7" data-post-type="script_updates" data-sticky-posts="" data-post-format="" data-category="" data-category-not-in="" data-tag="" data-tag-not-in="" data-taxonomy="" data-taxonomy-terms="" data-taxonomy-operator="" data-taxonomy-relation="" data-meta-key="" data-meta-value="" data-meta-compare="" data-meta-relation="" data-meta-type="" data-year="" data-month="" data-day="" data-author="" data-post-in="" data-post-not-in="" data-exclude="" data-search="" data-custom-args="" data-post-status="" data-order="DESC" data-orderby="date" data-offset="3" data-posts-per-page="5" data-lang="" data-scroll="false" data-scroll-distance="150" data-max-pages="0" data-pause-override="false" data-pause="true" data-button-label="Laad meer berichten" data-button-loading-label="Laden.." data-button-class="btn btn_custom load-more" data-destroy-after="" data-transition="slide" data-images-loaded="false"></div><div class="alm-btn-wrap"><button id="load-more" class="alm-load-more-btn more btn btn_custom load-more done">Laad meer berichten</button></div></div>
-
This reply was modified 8 years, 9 months ago by
christophvh.
Thanks, so is ID #202 the correct post ID for the page with the ACF fields?
Yes the page has a post ID of 202, the individual posts that have to be loaded are from a wp_query . So those are different id’s . Not sure if that is the problem.
Oh, so you are using this in a listing template?
This extension is for infinite scrolling ACF fields on a single post/page, not within a loop.
As seen in the examples here – https://connekthq.com/plugins/ajax-load-more/examples/advanced-custom-fields/
By your description, I don’t think you are using the extension how it is intended, in fact I don’t think you need the ACF extension at all.
If you are trying to display ACF fields in a standard loop, then have a look at this FAQ question.
https://connekthq.com/plugins/ajax-load-more/docs/faqs/#6
So, remove your acf shortcode paramters and try this repeater template.
<div class="update">
<?php
global $post;
while (have_rows('update_type', $post->ID)) : the_row();
?>
<?php if( get_row_layout() === 'video' ) : ?>
<div class="embed-responsive embed-responsive-16by9">
<?php echo get_sub_field('video_update', $post->ID) ?>
</div>
<?php endif ?>
<?php if( get_row_layout() === 'image') : ?>
<?php $image = get_sub_field('image_update', $post->ID); ?>
<img src="<?php echo $image['sizes']['large'] ?>" alt="<?php echo $image['alt'] ?>" class="author_image"/>
<?php endif ?>
<div class="update_content">
<span class="update_date"><?php the_date() ?></span>
<h3 class="update_title"><?php the_title() ?></h3>
<p class="update_text">
<?php the_excerpt() ?>
</p>
<?php if( get_row_layout() === 'file' ) : ?>
<?php
$file = get_sub_field('file_update', $post->ID)
?>
<a href="<?php echo $file['url'] ?>" title="<?php echo $file['title'] ?>" download>
<div class="file">
<i class="fa fa-file-o" aria-hidden="true"></i>
<div class="file_content">
<div class="file_title"><?php echo $file['title'] ?></div>
<span class="file_size"><?php echo $file['mime_type'] ?></span>
</div>
</div>
</a>
<?php endif ?>
<div class="list_social">
<?php echo wpfai_social() ?>
</div>
</div>
<?php endwhile; ?>
</div>
oh, i didn’t realise that. Yes that did the trick! Thank you very much for the good support!