• Resolved Maurice Vieth

    (@mauricevieth89)


    I am using ACF plugin for info window values.
    There is an attached file field and it is linked to media file(pdf).
    When I create a wpsl template and use the field, it is returning file ID not file url.
    How to get file url?

    https://prntscr.com/nygojs

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    If I understand it correctly then you will need to use this function to get the file URL.

    The ID your mentioning is the attachment ID, right? If not, and it’s an ACF based ID, then you will have to look in the ACF documentation for the correction function.

    Thread Starter Maurice Vieth

    (@mauricevieth89)

    Hi Tijmen,

    The ID is attachment ID. But the thing I need to get is attachment URL.

    There is an option to get File URL in ACF plugin. I set it.
    https://prntscr.com/nytmu9

    And I am using template file.
    https://prntscr.com/nytosh
    https://prntscr.com/nytpd7

    I think the problem is not related with using get_attached_file() function or ACF plugin functions.

    Please review it again.
    Thanks.

    Thread Starter Maurice Vieth

    (@mauricevieth89)

    Did you have a chance to look into this?

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Try this.

    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    
    function custom_store_meta( $store_meta, $store_id ) {
        
        $store_meta['menu_pdf'] = wp_get_attachment_url( $store_meta['menu_pdf'] );
        
        return $store_meta;
    }

    This assumes the menu_pdf holds the attachment ID.

    The code has to go in the functions.php inside your active theme folder.

    • This reply was modified 5 years, 9 months ago by Tijmen Smit.
    Thread Starter Maurice Vieth

    (@mauricevieth89)

    Thanks for your answer.

    It works well.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to get media file url from template?’ is closed to new replies.