문제

We use this code to display the link ...

$mp3Link = wp_get_attachment_url($mp3_file_id);
<a class="w3-black" href="'.$mp3Link.'" rel="nofollow" >mp3</a>

It looks like this now :

https://example.com/wp-content/uploads/2020/12/Amir.mp3

I want it to be like this :

https://sub.example.com/wp-content/uploads/2020/12/Amir.mp3

I mean, I just want to do this by editing the above code

도움이 되었습니까?

해결책

$mp3Link = wp_get_attachment_url($mp3_file_id);
$mp3Link = str_replace( 'example.com', 'sub.example.com', $mp3Link ); 
<a class="w3-black" href="'.$mp3Link.'" rel="nofollow" >mp3</a>

replace example.com with your actual domain - it's not the most elegant solution, but might work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top