wordpress - Get current URL with PHP and change a part of it for a new urlGet the solution ↓↓↓
I am working on a WordPress website for a client. I want to create a switch element through a current URL change. For instance;
echo $ _SERVER ['REQUEST_URI']; ?>
I have found a php code that provides me the URL of the current page. So if the visitor is on the /shop/customer page, I've found a way to create a shortcode and add my own string to it. But it creates a new link like; /shop/customer/owner
I want to replace customer in owner, not adding owner to the current link. Because it has to be a dynamic solution. For example, if the visitor is on https://mywebsite.com/shoppingcart/customer, they should change this to https://mywebsite.com/shoppingcart/owner
Sorry for the bad english, hope you understand what i need.
May be this could work!
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $change_url = str_replace("customer","shopping",$actual_link); echo $change_url;
People are also looking for solutions of the problem: sqlstate: integrity constraint violation: 1452 cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.