PHP   WordPress   

Get current page number in WordPress using PHP

function getCurrentPageNum($name){
	$URLParts = explode("/",$URL);
	$flag = 0;
	foreach ($URLParts as $index => $value){
		if($value == $name) $flag = $index;
	$page = $flag + 1;
	return $URLParts[$page];
$currentPageNum = getCurrentPageNum('page');
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us