How to get the URL of a uploaded file
-
Hola gente,
this is the first time i write here, up to now i always found a answer scanning throug the docs and th eforum, but not this time.i need to get the url of a uploaded file, which isn’ t embedded in the post content.
How can i do that?i tried the function
wp_get_attachment_url(52);but it doesn’t work. it doesn’t print out anything.
I called the function inside a loop:
<?php query_posts('cat=10'); //retrieves content from category 10/'materials' only ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h4><?php the_title(); ?></h4> <?php the_content(__('(more...)')); ?> <?php echo wp_get_attachment_url(52); ?> <?php endwhile; else: ?> <p><?php _e('Lo siento, no encuentro el contenido...'); ?></p> <?php endif; ?>i read somewhere that attachments have to be embedded in the post content to be recognized. But i can’t do this because i want to print out the post content somewhere else.
Anyway the function doesn’t work for me with the embedded upload neither.to explain a little more what i try to achieve:
My idea is to make a download page with grafic buttons, which are links and contain a title and a description text.
There are 3 diffrent types of buttons (text, grafic, video).So i created a category ‘downloads’ and every post of this category has additionally the tag ‘text’, ‘grafic’ or ‘video’.
From the post title and the post content i get the title and description of the file for the button (therefore i don’t want to embedd the file in the content). with the tag i can control which button image i use.But i need the url of the file to make the link work…
what can i do?
thanks for your help
flo
The topic ‘How to get the URL of a uploaded file’ is closed to new replies.