Add a word to the first // wp_get_attachment_url // as the subdomain name

wordpress.stackexchange https://wordpress.stackexchange.com/questions/380203

  •  22-04-2021
  •  | 
  •  

سؤال

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