How to update wordpress content
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;
}
I am using the above method to replace the url's with the new one and
update the content of the page but the page content is still the same so
please help me with this..
No comments:
Post a Comment