0
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;
}
我用上面的方法來代替網址用新的和更新網頁的內容,但頁面內容仍然是相同的,所以請幫助我這個WordPress的內容..如何更新
does'print $ content;'print as expected? – revo
print $ content打印所有被替換的網址及其相鄰的打印$ getdata不會返回具有更新的網址的網頁內容。 –