| |

Found $_SERVER in the file

It is a really wrong way to use $_SERVER. You can alternatively use the $wp global to get the current URL – it’s the same thing in the end though.

First, need to declare as global variable $wp.use following this

 global $wp

Then, add this code in your file, then you will get the current URL in the $url variable for this example:

$url = home_url(add_query_arg(array(), $wp->request));

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *