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.

  • 1
    Please show us the_field function code. Oct 6, 2011 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. Oct 6, 2011 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, 2011 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, 2011 at 16:17

1 Answer 1


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.

  • 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, 2011 at 16:20
  • No problem. No one can start with knowing each and every detail. :)
    – kaiser
    Oct 11, 2011 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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