Support

Account

Forum Replies Created

  • @dkeys222 I have the exact same issue. How do display only 1 row. now it returns the correct result but multiplied with the rows count. For example if i have 10 rows in the repeater, it returns the correct result but 10 times. have you worked it out?

    @acf-support

  • Hello @leem2209 ,

    I’m trying to achieve the same. The problem is that if i have 10 entries in my repeater, then i get as output the correct result x 10 times. how do you limit to get the output only once and not multiplied by the repeater rows?

  • Hello,

    How did you make that work? I used your code for a similar function but i cannot get it to work.

    My case is that we have 2 Post Categories. 1. Upcoming Events and 2.Passed Events.

    We create a post with ACF event_end_date which is an ACF Date picker. What we need to do is have a cron job that checks if the event_end_date has passed so it updates the Post Category from Upcoming Events to Passed Events. I just cant make it work. Here is the code if you guys got any input i would be thankful!

    /*  Scheduled Action Hook */
    function check_event_end_date() {
    
      global $post;
    
      $args = array( 
        'post_type' => 'post', 
        'post_status' => 'publish',
         'category__in' => array(33), /*Upcoming Events Category ID*/
        'posts_per_page'  => -1,
      );
    
      $listings = get_posts( $args );
        foreach($listings as $post) : setup_postdata($post);
    
      $today = date( 'Ymd' );
      $expire = get_field( 'event_end_date', false, false );
    
            if ( $expire > $today ) :
                $post_categories="36"; /*Passed Events Category ID*/
                $append=false;
                wp_set_post_categories( $post_ID, $post_categories, $append );
            endif;  
        endforeach;
    
    }
    
    // Schedule Cron Job Event
    
    if ( ! wp_next_scheduled( 'event_end_date_cron_job' ) ) {
        wp_schedule_event( date( 'Ymd' ), 'daily', 'event_end_date_cron_job' );
    }
    add_action( 'event_end_date_cron_job', 'check_event_end_date' );
Viewing 4 posts - 1 through 4 (of 4 total)