The File field’s documentation has some options you can try, but here’s an example if your field’s Return Value is array, where you can use $gradingForm['url']
to get the attachment URL:
$gradingForm = get_field( 'grading_form', $post_id );
echo $gradingForm ? '<a href="' . esc_url( $gradingForm['url'] ) . '">Grading Form</a>' : 'N/A';
And the proper way to use wp_get_attachment_url()
is by passing the attachment (post) ID as the only parameter like this: wp_get_attachment_url( 123 )
.
And in your case, here’s an example without using get_field()
:
$att_id = get_post_meta( $post_id, 'grading_form', true );
$gradingForm_url = wp_get_attachment_url( $att_id );