I'm trying to redirect users directly to the URL of the file located in a post using a File field from ACF. Something like:
<?php function redirect_to_acf_file_url() {
$file_url = get_field('file_url');
if (!empty($file_url)) {
wp_redirect($file_url, 301);
exit;
} }
do_action ('redirect_to_acf_file_url'); ?>
This would enable me to share the URL of the post and when users accesses the post URL, they'll go straight to the File url.
Right now, the above PHP just displays a blank page.
Would appreciate any help.
Thanks!