Automatically redirect 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.Every shop should check the domain and add the correct store id from the array.
$array= [
"apple.com" => "1234",
"microsoft.com" => "5678",
"dell.com" => "9876",
];
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) :
$offer_post_url = 'https://www.network./promotion/click/id=5678-yxz='.rawurlencode($offer_post_url);
endif;
if (!empty($offer_post_url) && strpos($offer_post_url, 'dell.com') !== false) :
$offer_post_url = 'https://www.network.com/promotion/click/id=9876-yxz='.rawurlencode($offer_post_url);
endif;
return $offer_post_url;
}
0
php, redirect
4 years
2020-03-24T12:51:10-05:00
2020-03-24T12:51:10-05:00 0 Answers
113 views
0
Leave an answer