Just trying to work out how to get the url of a file attached to a Post and displaying that in the admin page for that CPT. The file is attached to the post via an ACF file upload field called 'grading_form'
I have the Admin Page columns setup (using my custom plugin) and the data is populated in all of the columns (again, using the custom plugin).
Each post has a PDF form file attached to it. I would like to have a column in the admin page which has a link to the PDF file.
So far I have the following:
function toogee_grading_applications_column( $column, $post_id ) {
// Grading Form column
if ( 'grading_form' === $column ) {
$gradingForm = wp_get_attachment_url( 'grading_form' );
if ( ! $gradingForm ) {
_e( 'N/A' );
} else {
echo $gradingForm;
}
}
}
add_action( 'manage_grading_applications_posts_custom_column', 'toogee_grading_applications_column', 10, 2);
Note: I have other columns that are all working using the above format but I just removed them from this in the interests of shortening this post
Once I have the URL of the PDF file attachment, I was just going to enter something like the following in the else
statement to have a link in that column:
echo '<a href="'.$gradingForm.'">Grading Form</a>';
Unless there is a better way of doing it?
Thanks for any input