Support

Account

Home Forums General Issues Redirect to File URL Reply To: Redirect to File URL

  • I was able to get this to work:

    <?php
    function redirect_to_acf_file_url() {
      $file_url = get_field('file');
      if (!empty($file_url) && is_string( $file_url ) ) {
        wp_redirect( esc_url( $file_url ), 301);
        exit;
      }
    }
    redirect_to_acf_file_url();
    ?>

    But curiously, now when I add a New Post and attach a file, the same way I’ve done in the past. The Redirect doesn’t work on the new post. When I change an select a new File to attach in an Existing Post, it similarly breaks also.

    Please help!