Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Thanks

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);

if(is_array($value))
{
    $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
1  
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

1 Answer 1

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
1  
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

 
discard

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.