• Resolved christophvh

    (@christophvh)


    I’m using the the latest version of the plugin . With the latest version of ACF pro and the latest version of wordpress.

    I have this shortcode:

    do_shortcode('[ajax_load_more offset="3" id="single-collaboration" post_type="script_updates" repeater="template_7"  pause="true" scroll="false" button_label="Laad meer berichten" button_loading_label="Laden.."
                    acf="true" acf_field_type="flexible" acf_field_name="update_type"]')

    With this template file:

    <div class="update">
    	<?php if( get_row_layout() === 'video' ) : ?>
    		<div class="embed-responsive embed-responsive-16by9">
    			<?php echo get_sub_field('video_update') ?>
    		</div>
         <?php endif ?>
    
    	<?php if( get_row_layout() === 'image') : ?>
        	<?php $image = get_sub_field('image_update'); ?>
         		<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')
                                ?>
                                <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>
                    </div>

    The moment i remove the acf fields from the shortcode. The plugin works (without showing the acf fields.) But when i add the acf-tags it just does nothing. I have added a checkmark in the settings to show errors in the console, but even that does nothing.

    • This topic was modified 8 years, 9 months ago by christophvh.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    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?

    Thread Starter christophvh

    (@christophvh)

    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

    Plugin Author Darren Cooney

    (@dcooney)

    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.

    Thread Starter christophvh

    (@christophvh)

    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.
    Plugin Author Darren Cooney

    (@dcooney)

    Thanks, so is ID #202 the correct post ID for the page with the ACF fields?

    Thread Starter christophvh

    (@christophvh)

    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.

    Plugin Author Darren Cooney

    (@dcooney)

    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>
    Thread Starter christophvh

    (@christophvh)

    oh, i didn’t realise that. Yes that did the trick! Thank you very much for the good support!

    Plugin Author Darren Cooney

    (@dcooney)

    Woohoo!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘ACF extension does nothing’ is closed to new replies.