Support

Account

Forum Replies Created

  • You can use the acf/save_post action to check if the checkbox is checked and save the current time to the post meta. Then you can check the current time against the saved time in your template.

    Save the current time when the post is saved:

    
    <?php
    
    function my_acf_save_post( $post_id ) {
    	// Your checkbox field.
    	$checkbox_field = get_field( 'checkbox', $post_id );
    
    	// The post meta you'll be creating.
    	$checkbox_time = get_post_meta( $post_id, 'checkbox_saved_time', true );
    
    	/*
    	 * Add the current time to the post meta if your checkbox field is checked
    	 * and checkbox_saved_time doesn't already have a value saved.
    	 */
    	if ( $checkbox_field && ! $checkbox_time ) {
    		update_post_meta( $post_id, 'checkbox_saved_time', strtotime( 'now' ) );
    	}
    }
    
    add_action( 'acf/save_post', 'my_acf_save_post', 20 );
    
    ?>
    

    Compare the time in your template:

    
    <?php
    
    $checkbox_time = get_post_meta( $post_id, 'checkbox_saved_time', true );
    
    if ( $checkbox_time < strtotime( '-24 hours' ) ) {
    	// The checkbox was checked within the last 24 hours.
    }
    
    ?>
    
  • Do you have a width & height set on the .fill div?

  • What is the return type for the image field?

    If it’s array, there is an error but it’s printed into the inline styles so you can’t actually see it on the screen! So it’s kind of sneaky.

    To solve that you need to do <div class="fill" style="width: 100px; height: 100px; background-image: url(<?php echo get_sub_field('image')["sizes"]["full"] ?>);"></div> to get the image url from the array.

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