Support

Account

Forum Replies Created

  • Thanks for your answer John.
    I’m updating this post because I find a way to accomplish my goal :

    
    public function update_credits_acf( $post_id ) {
    
    $post_id = 137; // post_id of my CPT post
    
    $number_of_credits_available = get_field('credits_available', $post_id);
    $number_of_credits_action = get_field('number_of_credits');
    $number_of_credits_left = $number_of_credits_available - $number_of_credits_action;
    
    update_field('credits_available', $number_of_credits_left, $post_id);
    

    This code works, now my question is : How to dynamically retrieve the id of my CPT ? I have several posts so I can’t let “$post_id = 137;”.

    I tried some actions with get_the_ID(), the_ID()…

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