File URL

This topic contains 13 reply and 2 voices, and was last updated by Nathan 11 years ago
Viewing 13 Posts - 1 through 13 (of 13 total)
Author Posts
March 30, 2013 at 4:28 pm 1649
Nathan Is there any way to get just the URL of a file upload?
March 30, 2013 at 5:14 pm 1652
Tareq Hasan Tareq Hasan

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]

March 31, 2013 at 9:24 am 1670
Nathan Nathan

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

March 31, 2013 at 9:28 am 1671
Tareq Hasan Tareq Hasan

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]

March 31, 2013 at 10:02 am 1674
Nathan Nathan

Thanks Tareq. Your support is great 🙂 and your plugin is a life saver.

March 31, 2013 at 11:23 am 1675
Nathan Nathan

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?

March 31, 2013 at 12:13 pm 1676
Tareq Hasan Tareq Hasan

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

March 31, 2013 at 1:51 pm 1678
Nathan Nathan

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

March 31, 2013 at 2:13 pm 1680
Tareq Hasan Tareq Hasan

Can you give me login and ftp details?

March 31, 2013 at 2:18 pm 1681
Nathan Nathan

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

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

March 31, 2013 at 2:24 pm 1682
Tareq Hasan Tareq Hasan

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.

March 31, 2013 at 2:50 pm 1683
Nathan Nathan

I need an email address to set your account up…

March 31, 2013 at 2:52 pm 1684
Tareq Hasan Tareq Hasan

Email: support@wedevs.com

March 31, 2013 at 3:02 pm 1685
Nathan Nathan This reply has been marked as private.
Viewing 13 Posts - 1 through 13 (of 13 total)