• Resolved youngonline

    (@youngonline)


    So I’m using the custom field template plugin. I have numerous file fields defined in the template. When making a post I choose the files to upload and they do so.

    What i need to know is how i get the urls of the files that i uploaded into that specific post. They show up in the media library but it states they are not attached to any post, so i cant use the get_attachment_url method.

    I need it to display the url as one would type it, so http://www.example.com/blahblah.jpg

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter youngonline

    (@youngonline)

    Sorted.

    Dave Warfel

    (@analternateroute)

    youngonline,

    Care to share how you solved this issue? I’m experiencing the same challenge. I’ve uploaded a PDF, but when I try to display it on a page, all I get is a number (most likely an ID of some kind). But I can’t figure out how to get the URL.

    THanks,
    Dave

    Thread Starter youngonline

    (@youngonline)

    <?php $variable_name = get_post_meta($post->ID, 'Custom_Field_Name', true); ?>
    
    <?php if ($variable_name): ?>
    <?php echo wp_get_attachment_url($variable_name); ?>
    <?php endif; ?>

    Just replace variable_name with whatever you wish to call it and Custom_Field_Name with whatever you named the field in the plugin.

    Dave Warfel

    (@analternateroute)

    Just what I was looking for, young. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Field Plugin Get File URL’ is closed to new replies.