How to get current page url in wordpress?

by giovanny.lueilwitz , in category: Third Party Scripts , 5 months ago

How to get current page url in wordpress?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elisha_langworth , 5 months ago

@giovanny.lueilwitz 

You can get the current page URL in WordPress by using the following PHP code:

1
2
$current_url = home_url(add_query_arg(array(),$wp->request));
echo $current_url;


This code will retrieve the current URL of the page you are on and store it in the $current_url variable. You can then use this variable to display or use the URL in your WordPress website.

Related Threads:

How to get current page name in wordpress?
How to get title of current page with woocommerce?
How to add page pagination on custom wordpress page?
How to check if current url is valid in laravel?
How to refresh page by button in wordpress?
How to get url in Drupal 8?