Support

Account

Home Forums General Issues How to pass variable to the_field? Reply To: How to pass variable to the_field?

  • First the_field() is only used to display fields. To use the value of the field somewhere else you need to use get_field()

    You also need the post ID of the post where that other field appears. Basically, what you need is a post object field that returns the ID and the field name you want to put from that page.

    Then, in long form

    
    // get the field and post ID from this post
    $field_name = get_field('field name of field containing field name');
    $post_id = get_field('field name of post object field that has the above field');
    
    // show the value from that other post
    the_field($field_name, $post_id);