Home Forums Front-end Issues Field output not showing


Field output not showing

  • hi,
    First of all thank ACF for the amazing plugin. I am working on wordpress tube theme. I want to add a custom field named download,a url base field.
    It shows in the video post edit panel but not showing at frontend. Any help should be appreciated.
    My Feild group key
    Feild Name

  • Are you meaning for your end user to download a file? If you use URL as the field type, it will take you to the url. By using the File field type, you can select ‘File URL’ as the return value and then on the php page use:

    $file = get_field('download');
    if( $file ): ?>
        <a href="<?php echo $file['url']; ?>"><?php echo $file['filename']; ?></a>
    <?php endif; ?>

    to grab the value on the front end. Then when the link is clicked, the download will be done automatically.

  • I want to add url because i stored my downloadable files on external file hosting site. and in which theme options include the code?

  • Okay so you should use the following:

    $download = get_field('download');
    if( $download ): ?>
        <a class="button" href="<?php echo esc_url( $download ); ?>">Download File</a>
    <?php endif; ?>

    This would go in the php template file with the other content for the page you wish to add it to.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.