This topic is: resolved

Tagged: 

This topic contains 13 replies, has 2 voices, and was last updated by  Nathan 6 years, 1 month ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1649

    Nathan
    Participant
    Post count: 32

    Is there any way to get just the URL of a file upload?

    #1652

    Tareq Hasan
    Keymaster
    Post count: 2831

    There is a shortcode to display link from a meta key: [wpuf-meta name="meta_key_name" type="file"].

    If you want it in code level, here's how:
    [php]
    $files = get_post_meta( $post->ID, ‘mey_key_name' );

    if ($files) {
    foreach ($files as $attachment_id) {
    $full_url = wp_get_attachment_url( $attachment_id );
    }
    }
    [/php]

    It's for multiple files with the same meta key. If you have single file in a meta key, then it's simpler-
    [php]
    $full_url = wp_get_attachment_url( get_post_meta( $post->ID, ‘mey_key_name', true ) );
    [/php]

    #1670

    Nathan
    Participant
    Post count: 32

    That shortcotee returns full hyperlink. I need just the URL to the file without the surrounding a tag. Is this possible?

    #1671

    Tareq Hasan
    Keymaster
    Post count: 2831

    Thats why I gave you three solutions. Use the last one, paste it in your themes single.php where you want to show the url.
    [php]
    $full_url = wp_get_attachment_url( get_post_meta( $post->ID, ‘mey_key_name', true ) );
    echo $full_url;
    [/php]

    #1674

    Nathan
    Participant
    Post count: 32

    Thanks Tareq. Your support is great ๐Ÿ™‚ and your plugin is a life saver.

    #1675

    Nathan
    Participant
    Post count: 32

    I've added it to my file like so:

     

    <?php $full_url = wp_get_attachment_url( get_post_meta( $post->ID, ‘voucher_file', true ) );

    echo $full_url; ?>

     

    But it isn't returning anything. Am I doing it wrong?

    #1676

    Tareq Hasan
    Keymaster
    Post count: 2831

    Do you actually have any value in that custom field? If it's there, should be ok.

    #1678

    Nathan
    Participant
    Post count: 32

    Yep, just double checked. Here's a test URL if that helps:http://bigbird.wearesmile.com/~shakes/passport-vouchers/tester/

    #1680

    Tareq Hasan
    Keymaster
    Post count: 2831

    Can you give me login and ftp details?

    #1681

    Nathan
    Participant
    Post count: 32

    Yes, but not publicly. can you send me your email?

    All code in thesis skin editor, through wordpress admin, woultaught be ok?

    #1682

    Tareq Hasan
    Keymaster
    Post count: 2831

    You can post the details here as a private reply, that should be okay. I have no idea about thesis, but if the shortcode works fine and not the code, then may be some compatibility problem with thesis.

    #1683

    Nathan
    Participant
    Post count: 32

    I need an email address to set your account up…

    #1684

    Tareq Hasan
    Keymaster
    Post count: 2831
    #1685

    Nathan
    Participant
    Post count: 32
    This reply has been marked as private.
Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘File URL’ is closed to new replies.