WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a custom post type with a file upload field. In my template file i'm using this to display a link to that file.

<a href="<?php the_field('downloads'); ?>">Download PDF</a>

What i want is to be able to have it display the file title. So instead of Download PDF it will say the files title.

What php would go inside the code i'm using?


EDIT: Here's the code that i put in the comment below. I'm guessing this is what you were asking for. I looked through the files for the plugin i've used and found this function.

function the_field($field_name, $post_id = false)


$value = get_field($field_name, $post_id);

    $value = @implode(', ',$value);

echo $value;


Please let me know if this isn't what you meant or you need to know anything else.

share|improve this question
Please show us the_field function code. – Brian Fegter Oct 6 '11 at 14:29
What @BrianFegter said; your question is entirely unanswerable as-is, since you're asking about custom code that none of us has seen. – Chip Bennett Oct 6 '11 at 15:39
I've created the custom post type and the custom fields using plugins. I'm using the code i've put above to call that custom field. I haven't added any code to the function.php – Corbula Oct 6 '11 at 15:41
Sorry i think i understand now. I think this is what you wanted to know. function the_field($field_name, $post_id = false) { $value = get_field($field_name, $post_id); if(is_array($value)) { $value = @implode(', ',$value); } echo $value; } I got confused and thought the_field was a generic wordpress function. – Corbula Oct 6 '11 at 16:17
up vote 1 down vote accepted

I've used a work around for this.

Instead of using the title name for the file i've added another field to use as the title. Not the way i intended but it works.

share|improve this answer
Please mark this as solution to let it not stay under "Unanswered". Thanks. Anyway: +1 for finding the solution and posting it. – kaiser Oct 11 '11 at 16:20
Thanks for letting me know, I didn't realise. – Corbula Oct 11 '11 at 16:31
No problem. No one can start with knowing each and every detail. :) – kaiser Oct 11 '11 at 16:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.