Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get current url in wordpress
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
@MishukAdhikari

This comment has been minimized.

Copy link

@MishukAdhikari MishukAdhikari commented Jun 14, 2018

$current_url = home_url($_SERVER['REQUEST_URI'])

@Divyesh71

This comment has been minimized.

Copy link

@Divyesh71 Divyesh71 commented Nov 26, 2018

Thanks @MishukAdhikari

Your answer is worked for me!

$current_url = home_url($_SERVER['REQUEST_URI']);

@FathomCode

This comment has been minimized.

Copy link

@FathomCode FathomCode commented Apr 28, 2020

Thanks @MishukAdhikari
Your answer
worked for me too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment