Support

Account

Home Forums Front-end Issues ACF works perfect locally, completely fails live.

Solved

ACF works perfect locally, completely fails live.

  • MikaelaSheldt.com

    Is the site. Locally, the satement and gallery tabs are accompanied by video and poetry tabs (which are included dynamically) and the tabs should exist if:

    get_field("something") == true

    And when that returns true:

    the_field("something")

    Prints it’s content. Since I launched the site, I have completely failed in even getting the content to budge. I can’t think of anything to even try.

    Has anyone seen this before?

    I’m happy to include more information if someone needs it to help diagnose this problem.

  • Hi @atotalpirate

    Can you please make sure your post contains the data for these fields.
    Looking at your site, you only have a ‘hello world’ post which makes me think you don’t have any data yet.

    Perhaps also make sure you don’t have any caching turned on.

    Thanks
    E

  • Below is the code for posts page. The ‘Hello World’ post has dummy content in each field and has been posted and updated multiple times.

    I know it looks like I left out the content and what’s weirder is, while video and poetry content do exist, their tabs are non existent unlike the state and gallery tabs. But while those tabs exist, they’re empty even though there is post data submitted for each content type.

    I don’t have any caching plugins installed, could there be a caching setting set by my hosting service by default? I host with ipage.com if that helps.

    <?php 
    get_header();
    $idObj = get_category_by_slug('category-name'); 
    $id = $idObj->slug;
    $ftimg = wp_get_attachment_url( get_post_thumbnail_id($post->ID));
    $statementTrue = get_field( "statement" );
    $galleryTrue = get_field("image_gallery");
    $videoTrue = get_field("video_embed");
    $poetryTrue = get_field("poem_1");
     ?>
    
    <div id="single">
    
    	<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    		
    		<div id="tabs">
    			
    			<section class="post-title" style="background-image: url(<?php echo $ftimg; ?>); background-size: cover; background-position-y: 50%;">
    				<div id="titleoverlay">
    					<h1 class="titles title"><?php the_title(); ?></h1>
    				</div>
    				<?php include("includes/tabnav.php"); ?>
    			</section>
    			
    		<?php if ( $statementTrue == true ) : ?>
    		
    		  <div id="statement-tab">
    	
    		    <?php get_template_part('content', 'statement'); ?>
    		    
    		    <div id="social-footer">
    		    	<?php include('includes/social-footer.php'); ?>
    		    </div>
    		    
    		  </div><!--end statement-tab-->
    		  
    		<?php endif; ?>
    		
    		<?php if ( $galleryTrue == true ) : ?> 
    		 
    		  <div id="gallery-tab">
    		   
    		    <?php get_template_part('content', 'gallery'); ?>
    		    
    		    <div id="social-footer">
    		    	<?php include('includes/social-footer.php'); ?>
    		    </div>
    		    	
    		  </div><!--end gallery-tab-->
    		  
    		<?php endif; ?>
    		
    		
    		<?php if ( $videoTrue == true ) : ?>	  
    	
    		  <div id="video-tab">
    		    
    		    	<?php get_template_part('content', 'video'); ?>
    		    	
    		    	<div id="social-footer">
    		    		<?php include('includes/social-footer.php'); ?>
    		    	</div>
    		    	
    		  </div><!--end video-tab-->
    		  
    		<?php endif; ?>
    		  
    		<?php if ( $poetryTrue == true ) : ?>
    		  
    		  <div id="poetry-tab">
    		    
    		  	<?php get_template_part('content', 'poetry'); ?>
    		    
    		  </div><!--end-poetry tab-->
    		
    		<?php endif; ?>
    		
    		</div>
    		
    		
    	<?php endwhile; else: ?>
    	
    		<p class="noposts">Nope. No posts. single.</p>
    
    	<?php endif; ?>
    		
    <?php get_footer(); ?>
    
    </div>
  • Hi @atotalpirate

    It is possible that your server is providing some sort of DB or persistent cache.

    Before asking them, can you please move all your ACF code INSIDE the WP loop. You may find that this solves the issue.

    Also, can you please debug all your variables to check the data?

    Thanks
    E

  • I just vardumped all of the variables I set to determine if content exists or not:

    $statementTrue = get_field( "statement" );
    $galleryTrue = get_field("image_gallery");
    $videoTrue = get_field("video_content") && get_field("video_embed");
    $poetryTrue = get_field("poem_1");

    And I got the correct data for statement and gallery but false on the other two.

    I doubled checked that the content was posted and that the field names were correct, they were posted and the names are right.

    EDIT: I also checked for get_field(“video_content”) and get_field(“video_embed”) separately. They both returned false.

    The only way I could get ACF post data to display was to include only the $statementTrue variable. Adding the gallery variable broke it again even though it gave me my content when I vardumped.

  • Hi Can you please debug the post ID?

    You can get he post ID like so:
    $post_id = get_the_ID();

    Make sure this is the correct ID that you are expecting.

    Thanks
    E

  • Hi Elliot,

    I just var_dumped $post_id = get_the_ID(); and it returns int(1078)

    I have no idea what that could mean.

    Shouldn’t I be expecting the post name as my id?

    Also, thanks for taking an interest in my issue.

  • Hi @atotalpirate

    Shouldn’t I be expecting the post name as my id?
    No, the get_the_ID(); function returns the post’s ID, not the post’s title.

    Can you confirm that post 1078 contains the correct data you expect?

    Thanks
    E

  • Alright, I’m a little confused but I’m pretty sure my “Hello World” post ID should be 1.

    When I enter this /?attachment_id=1 to my sites URl, I get my post.

    When I add 1078, however, I get this garbage..

    I’m hoping this gives some insight?

  • UPDATE: I posted this tread on stackoverflow.com and someone suggested that it was a database issue (which I’m betting you were arriving at, Elliot) so I dropped all old live db’s and imported my local one and everything works just fine now.

    Thanks for your help!

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

The topic ‘ACF works perfect locally, completely fails live.’ is closed to new replies.