Automatically change links in posts
Question
I have found a solution to change links in my wordpress theme, but not the links in the content. How is it possible to get the URL in the content, so I can also changed them?
Maybe someone can me help find a solution, where I can add more stores with less code. Domain example.com with an ID from an network like id=28273527.
My function looks like this:
function link_change_custom($offer_post_url){
if (!empty($offer_post_url) && strpos($offer_post_url, 'apple.com') !== false) :
$apple = 'https://www.network.com/promotion/click/id=1234-yxz=';
$offer_post_url = $apple .rawurlencode($offer_post_url);
endif;
if (!empty($offer_post_url) && strpos($offer_post_url, 'microsoft.com') !== false) :
$microsoft= 'https://www.network./promotion/click/id=5678-yxz=';
$offer_post_url = $microsoft.rawurlencode($offer_post_url);
endif;
if (!empty($offer_post_url) && strpos($offer_post_url, 'dell.com') !== false) :
$dell= 'https://www.network.com/promotion/click/id=9876-yxz=';
$offer_post_url = $dell.rawurlencode($offer_post_url);
endif;
return $offer_post_url;
}
0
php, redirect, urls
4 years
2020-03-23T12:51:50-05:00
2020-03-23T12:51:50-05:00 0 Answers
106 views
0
Leave an answer