add_filter('the_content','filter_trendland_content');
//create a the function to get the content of the page by using the hook the_content
function filter_trendland_content($content) {
$getdata = $content;
if (preg_match_all('#(?:<a.+?href=["|\'](?P<link_url>.+?)["|\'].*?>\s*)?(?P<img_tag><img.+?src=["|\'](?P<img_url>.+?)["|\'].*?>){1}(?:\s*</a>)?#is', $getdata, $images)) {
foreach ($images[img_url] as $key => $value) {
$subdomain = rand(1, 3);
$newurl="yaseen.media$subdomain.com";
$content = preg_replace('/\bmedia.trendland.com\b/', $newurl, $value);
print $content;
}
print $getdata;
}
//return $getdata;
}
Я использую вышеупомянутый метод для замены URL, с новым и обновить содержимое страницы, но содержимое страницы по-прежнему такой же поэтому, пожалуйста, помогите мне с этим ..Как обновить WordPress содержание
делает 'print $ content;' печатает как ожидалось? – revo
print $ content печатает все замененные URL-адреса и его прекрасную печать $ getdata не возвращает содержимое страницы с обновленными URL-адресами. –