Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File path without domain name from wp_get_attachment_url()

wp_get_attachment_url() process full file path like

http://example.com/wp-content/uploads/2014/12/aura.mp3

I want the url without http://example.com/ So, I want above example as wp-content/uploads/2014/12/aura.mp3 instead of http://example.com/wp-content/uploads/2014/12/aura.mp3. How to do it?

like image 842
Sahriar Saikat Avatar asked Oct 19 '22 19:10

Sahriar Saikat


1 Answers

You can really easily explode it by / and then take the part with index 3. Example

$url = wp_get_attachment_url(id); //id is file's id
$urllocal = explode(site_url(), $url)[1]; //output local path
like image 63
Roope Hakulinen Avatar answered Oct 31 '22 09:10

Roope Hakulinen