Custom Fields Creator
[resolved] Attachment URL for a PDF Link (2 posts)

  1. David Ruszkowski
    Posted 3 years ago #

    I am having some trouble (probably something I am doing wrong) with showing a link to a PDF that I am adding to a custom post type with the upload field. I am getting a link to show that looks right but the URL itself is not correct.

        $pdfdownloadlink = get_post_meta($post->ID, 'pdfdownloadlink', true);
        foreach($pdfdownloadlink as $pdfdownloadlink) {
            $file_attributes = wp_get_attachment_url( $pdfdownloadlink['file-upload'] );
            echo '<a href="' . $file_attributes[0] . '" >';
    	echo $pdfdownloadlink['file-link-name'];

    pdfdownloadlink = Meta Box Argument
    file-upload = The Upload Field
    file-link-name = A Text Field for the text that shows the link

    The temp URL for an example of this is: http://buffalomedia.net/hosted-sites/nyafp/event/htst/

    In this example the URL that is supposed to be showing under "File Download" would be: http://buffalomedia.net/hosted-sites/nyafp/wp-content/uploads/2013/03/HTST.pdf

    The URL it is showing is: http://buffalomedia.net/hosted-sites/nyafp/event/htst/h

    It is probably something that I am missing, any help anyone can offer would be great! Thanks.


  2. David Ruszkowski
    Posted 3 years ago #

    Nevermind I figured this out, I got rid of the [0] after $file_attributes. Seems to work good now.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Fields Creator
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic