admin管理员组文章数量:1394184
In my template i'm using a link for downloading a file (probably a PDF or a JPEG) that I will upload from Media Library. How can I get the url path for this specific file? What template tag I have to use?
Thanks
In my template i'm using a link for downloading a file (probably a PDF or a JPEG) that I will upload from Media Library. How can I get the url path for this specific file? What template tag I have to use?
Thanks
Share Improve this question asked Mar 3, 2020 at 18:04 Antonino LatteneAntonino Lattene 1431 gold badge2 silver badges12 bronze badges 6- How is the file connected to the page/post in the template? How do you tell it apart from all the other files – Tom J Nowell ♦ Commented Mar 3, 2020 at 18:43
- I'm not sure what you mean.. I need to have this link in the home (front-page.php). Is that what you meen? – Antonino Lattene Commented Mar 3, 2020 at 20:04
- This one will get you the media-url from the unique-id of the media-item developer.wordpress/reference/functions/… – admcfajn Commented Mar 3, 2020 at 21:19
- I mean if you want to show a file you've uploaded in a place, you need to know its ID and have that stored somewhere, but if all you've done is go to the media section and uploaded it, how do we know which file you meant to display? Have you considered just having a page as your front page, and using a file block? Or inserting an attachment into the page as a link? – Tom J Nowell ♦ Commented Mar 3, 2020 at 21:56
- Maybe I am a bit confused about how to get it.. Let me give you more context...I just want to have a link in my home page, so when users click on it they will download my CV... I thought i needed to upload it by Media Library and then get the URL through some template tag and put it in my page.. This is not the right way to do it? – Antonino Lattene Commented Mar 3, 2020 at 23:50
3 Answers
Reset to default 0All uploads to Media Library have their link saved. Click on the image, find the Details Section. Click on More Details.
you should create custom field and place media url in that, call custom fields in home page by code. Reference URL: https://www.wpbeginner/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/
I think that the best way is to upload the file in a separate folder from media library and then call it by using get_stylesheet_directory_uri();
For example: dist/img/cv.pdf">
本文标签: linksHow can I get the url from file uploaded in Media Library
版权声明:本文标题:links - How can I get the url from file uploaded in Media Library 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744692334a2620069.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论