Support

Account

Home Forums ACF PRO Refresh Data on Page

Solving

Refresh Data on Page

  • We’ve run into an issue with a schedule we create via ACF. The schedule is updated and saves fine in WP.

    It also shows fine on the schedules page but only if you haven’t already been to the page(browser’s cache shows otherwise) or hit refresh on the page.

    It’s weird though. I have a custom link in the WP Menu with the full URL for the page, yet it still shows the cached page.

    I’m not sure if there is a way within a page to update the ACF data every few minutes without refreshing the page. Is that possible?

    camelotshowbar.com/dancers

  • Hi @lcg_1111

    I’ve just checked your website, and it looks great on my end. I refreshed several times, and the schedules were showing up. Could you please share some screenshots of the issue?

    If you want to refresh the data without refreshing the page, you need to use AJAX. This page should give you more idea about it: https://codex.wordpress.org/AJAX_in_Plugins.

    I hope this helps. Thanks!

  • We are narrowing the issue down. This will be a last ditch effort to alleviate the problem.

    The issue is that browsers are caching the page. So instead of showing an updated page, it shows an old schedule. Google Chrome is the biggest culprit. Still working around it’s issues.

  • Maybe something is up with my template for this page.

    <?php
    /**
     * Template Name: Schedule Page
     *
     */
    get_header();
    
    $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
    
    ?>
    
    <div id="main-content">
    
    <?php if ( ! $is_page_builder_used ) : ?>
    
    	<div class="container">
    		<div id="content-area" class="clearfix">
    			<div id="left-area">
    
    <?php endif; ?>
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    				<div class="entry-content">
                    <!-- START Schedules Content -->
    					<div class="et_pb_section  et_pb_section_0 et_section_regular">
    				
    				
    					
    					<div class=" et_pb_row et_pb_row_0">
    				
    				<div class="et_pb_column et_pb_column_4_4 et_pb_column_0">
    				<div id="SchedulePageTopContainer">
    				<div class="et_pb_text et_pb_module et_pb_bg_layout_light et_pb_text_align_left  et_pb_text_0">
    				<?php $image = wp_get_attachment_image_src(get_field('side_image'), 'full'); ?>
    <!-- START Page Image -->
    <div class="ScheduleLeft"><img class="size-full ScheduleImage" src="<?php echo $image[0]; ?>" alt="<?php echo get_the_title(get_field('side_image')) ?>" /></div>
    <!-- END Page Image -->
    
    <div class="ScheduleRight">
    <!-- START Page Title -->
    <?php
    if(get_field('page_title'))
    {
    	echo '<h1 class="ScheduleHeadline">' . get_field('page_title') . '</h1>';
    }
    ?>
    <!-- END Page Title -->
    <!-- START Day Hours -->
    <?php
    if(get_field('day_hours'))
    {
    	echo '<p class="ScheduleHours"><img class="alignleft size-full wp-image-159 ScheduleIcon" src="http://camelotshowbar.com/wp-content/uploads/2015/09/DayKeyIcon1.png" alt="DayKeyIcon" width="170" height="50" />' . get_field('day_hours') . '</p>';
    }
    ?>
    <!-- END Day Hours -->
    <!-- START Night Hours -->
    <?php
    if(get_field('night_hours'))
    {
    	echo '<p class="ScheduleHours"><img class="alignleft size-full wp-image-159 ScheduleIcon" src="http://camelotshowbar.com/wp-content/uploads/2015/09/NightKeyIcon1.png" alt="DayKeyIcon" width="170" height="50" />' . get_field('night_hours') . '</p>';
    }
    ?>
    <!-- END Day Hours -->
    <!-- START Page Title -->
    <?php
    if(get_field('weekly_shoutout'))
    {
    	echo '<h2 class="ScheduleShout">' . get_field('weekly_shoutout') . '</h2>';
    }
    ?>
    <!-- END Page Title -->
    </div>
    
    			</div> <!-- .et_pb_text -->
    </div><!-- /SchedulePageTopContainer -->
    <div class="et_pb_text et_pb_module et_pb_bg_layout_light et_pb_text_align_left  et_pb_text_1">
    				
    <div id="ScheduleHeader">
    <table id="TableHeader">
    <tbody>
    <tr>
    	<td class="column-1">&nbsp;</td><td class="column-2"><span class="Mon"></span></td><td class="column-3"><span class="Tue"></span></td><td class="column-4"><span class="Wed"></span></td><td class="column-5"><span class="Thu"></span></td><td class="column-6"><span class="Fri"></span></td><td class="column-7"><span class="Sat"></span></td><td class="column-8"><span class="Sun"></span></td>
    </tr>
    </tbody>
    </table>
    </div><!-- /ScheduleHeader -->
    
    <div id="Schedule">
    <?php 
    
    // get repeater field data
    $repeater = get_field('employee_schedule');
    
    // vars
    $order = array();
    
    // populate order
    foreach( $repeater as $i => $row ) {
    	
    	$order[ $i ] = $row['name'];
    	
    }
    // multisort
    array_multisort( $order, SORT_ASC, $repeater );
    
    // loop through repeater
    if( $repeater ): ?>
    
    	<table id="ScheduleTable">
    
    	<?php foreach( $repeater as $i => $row ): ?>
    
    		<tr>
            <td class="column-1"><?php echo $row['name']; ?></td>
            <!-- START MONDAY -->
            <td class="column-2">
    		<?php $field = $row['monday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
    
    		</td>
            <!-- END MONDAY -->
            <!-- ------------------------ -->
            <!-- START TUESDAY -->
            <td class="column-3"><?php $field = $row['tuesday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
               </td>
            <!-- END TUESDAY -->
            <!-- ------------------------ -->
            <!-- START WEDNESDAY -->
               <td class="column-4"><?php $field = $row['wednesday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
               </td>
            <!-- END WEDNESDAY -->
            <!-- ------------------------ -->
            <!-- START THURSDAY -->   
            <td class="column-5"><?php $field = $row['thursday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
               </td>
            <!-- END THURSDAY -->
            <!-- ------------------------ -->
            <!-- START FRIDAY -->
            <td class="column-6"><?php $field = $row['friday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
               </td>
            <!-- END FRIDAY -->
            <!-- ------------------------ -->
            <!-- START SATURDAY -->
            <td class="column-7"><?php $field = $row['saturday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
               </td>
            <!-- END SATURDAY -->
            <!-- ------------------------ -->
            <!-- START SUNDAY -->
            <td class="column-8"><?php $field = $row['sunday']; ?>
            <?php if( in_array('Day', $field) && in_array('Night', $field)) {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/DayNight.png"; 
    			$ImageIconAlt ="Day and Night"; 
    		} elseif (in_array('Day', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Day.png"; 
    			$ImageIconAlt ="Day"; 
    		} elseif (in_array('Night', $field)){
    			$ImageIcon ="/wp-content/themes/Divi-child/images/Night.png"; 
    			$ImageIconAlt ="Night"; 
    		} else {
    			$ImageIcon ="/wp-content/themes/Divi-child/images/spacer.gif"; 
    			$ImageIconAlt ="Off";
    		}
    		?>
    			
               <img src="<?php echo $ImageIcon; ?>" class="DayNightCircle" alt="<?php echo $ImageIconAlt; ?>"/>
               </td>
            <!-- END SUNDAY -->
    
            </tr>
    
    	<?php endforeach; ?>
    
    	</table>
    
    <?php endif; ?>
    </div>
    
    			</div> <!-- .et_pb_text -->
    			</div> <!-- .et_pb_column -->
    					
    			</div> <!-- .et_pb_row -->
    				
    			</div> <!-- .et_pb_section -->
    					</div> <!-- .entry-content -->
    
    				</article> <!-- .et_pb_post -->
    
    			<?php endwhile; ?>
    
    <?php if ( ! $is_page_builder_used ) : ?>
    
    			</div> <!-- #left-area -->
    
    			<?php get_sidebar(); ?>
    		</div> <!-- #content-area -->
    	</div> <!-- .container -->
    
    <?php endif; ?>
    
    </div> <!-- #main-content -->
    
    <?php get_footer(); ?>
  • Hi @lcg_1111

    Maybe you have a cache plugin or your server uses a cache feature. If you have a cache plugin, could you please clear the cache and deactivate it for awhile? If you don’t have, could you ask your server if they have a cache feature?

    I hope this helps. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Refresh Data on Page’ is closed to new replies.