Title: Get Url file
Last modified: May 2, 2019

---

# Get Url file

 *  Resolved [cyberespia](https://wordpress.org/support/users/cyberespia/)
 * (@cyberespia)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/get-url-file/)
 * Currently the url of the file is:
    `https://myhost.com/?attachment_id=847&download_file
   =5cb6534b0fd32&_wpnonce=ba84e0634f` how can I get the url of the file directly(
   I need it this way to be able to add a PDF viewer) `https://myhost.com/wp-content/
   uploads/2019/04/myfile.pdf`
 * I have looked in:
    `public/class-woocommerce-product-attachment-public`
 *  `$wcpoa_file_url_btn = '<a class="wcpoa_attachmentbtn" href="' . esc_url(get_permalink().
   esc_attr($wcpoa_attachment_url_arg) . 'attachment_id=' . esc_attr($attachment_id).'&
   download_file=' . esc_attr($wcpoa_attachments_id) . '&_wpnonce=' . esc_attr($
   nonce)) . '" rel="nofollow">' . __("Download", 'woocommerce-product-attachment').'
   </a>'`

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

 *  [thedotstore](https://wordpress.org/support/users/thedotstore/)
 * (@thedotstore)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/get-url-file/#post-11492808)
 * Hello [@cyberespia](https://wordpress.org/support/users/cyberespia/),
 * This is server specific issue so, we need to debug in details.
 * Create support ticket from [here](https://www.thedotstore.com/support/) so, our
   technical team contact you soon.
 * Thanks,
 *  Thread Starter [cyberespia](https://wordpress.org/support/users/cyberespia/)
 * (@cyberespia)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/get-url-file/#post-11493155)
 * I have already solved it, with this I get the complete url of the file:
 * `$wcpoa_file_url_btn = '<a class="wcpoa_attachmentbtn" href="' . wp_get_attachment_url(
   esc_attr($attachment_id)) . '" rel="nofollow">' . __("Download", 'woocommerce-
   product-attachment') . '</a>';`
 *  [thedotstore](https://wordpress.org/support/users/thedotstore/)
 * (@thedotstore)
 * [7 years ago](https://wordpress.org/support/topic/get-url-file/#post-11516013)
 * Hello [@cyberespia](https://wordpress.org/support/users/cyberespia/),
 * Thanks for the update and congrats for resolved the issue.
 * Let us know in future if any help need from us we are happy to help!
 * Thanks,
 *  [pirata87](https://wordpress.org/support/users/pirata87/)
 * (@pirata87)
 * [7 years ago](https://wordpress.org/support/topic/get-url-file/#post-11569728)
 * I did what [@cyberespia](https://wordpress.org/support/users/cyberespia/) said
   or I understood:
    - <?php echo $wcpoa_file_url_btn = ‘[‘ . __(“Download”, ‘woocommerce-product-attachment’) . ‘](https://wordpress.org/support/topic/get-url-file/&apos; . wp_get_attachment_url(esc_attr($attachment_id)) . &apos;?output_format=md)‘;?
      >
    - But it doesn’t work for me. I wrote this code into “content-single-product.
      php” because i want to include in a curstom aside product, not into tabs section
      which I deleted.
 *  Plugin Author [Dotstore](https://wordpress.org/support/users/dots/)
 * (@dots)
 * [7 years ago](https://wordpress.org/support/topic/get-url-file/#post-11571045)
 * Hello [@pirata87](https://wordpress.org/support/users/pirata87/),
 * Thanks for reaching out to us.
 * I have notice that, you have copy only one line of the code from the file so,
   that’s why you are unable to get the attachment URL.
 * Please read below steps how you can get attachment file URL or download link.
 * You need to copy the code of the function name is “**wcpoa_new_product_tab_content**”
   at **Line no**: 223 and the file path is: “plugins\woo-product-attachment\public\
   class-woocommerce-product-attachment-public.php”.
    After copy the code please
   make sure that you are getting the Product ID in $post->ID this variable other
   wise this code will not work.
 * If you are getting trouble during the code integration as per your requirement
   please create support ticket so we can help you for the same.
 * [Create support ticket.](https://www.thedotstore.com/support/)
 * OR you can just copy this shared code.
 * [Click here](https://codeshare.io/G8BQ1A) to copy shared code in which you just
   need to change the product ID and you will get all the attachment links.
 * Let me know still you have any query on this.
 * Thanks,
    -  This reply was modified 7 years ago by [Dotstore](https://wordpress.org/support/users/dots/).
 *  [webcihakan](https://wordpress.org/support/users/webcihakan/)
 * (@webcihakan)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/get-url-file/#post-11623020)
 * meta.php add code url button tab delete ? $wcpoa_file_url_btn = ‘[‘ . __(“Download”, ‘woocommerce-product-attachment’) . ‘](https://wordpress.org/support/topic/get-url-file/&apos; . esc_url($a_tag_url . &apos;&_wpnonce=&apos; . esc_attr($nonce)) . &apos;?output_format=md)‘;
 *  [thedotstore](https://wordpress.org/support/users/thedotstore/)
 * (@thedotstore)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/get-url-file/#post-11637925)
 * Hello [@webcihakan](https://wordpress.org/support/users/webcihakan/),
 * Thanks for sharing the code snippet.
 * You can also review our previous message for how to get attachment url.
 * Let us know still you have any query.
 * Thanks,

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

The topic ‘Get Url file’ is closed to new replies.

 * ![](https://ps.w.org/woo-product-attachment/assets/icon-256x256.png?rev=3011306)
 * [Product Attachment for WooCommerce](https://wordpress.org/plugins/woo-product-attachment/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-product-attachment/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-product-attachment/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-product-attachment/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-product-attachment/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-product-attachment/reviews/)

 * 7 replies
 * 5 participants
 * Last reply from: [thedotstore](https://wordpress.org/support/users/thedotstore/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/get-url-file/#post-11637925)
 * Status: resolved