Support » Fixing WordPress » Static page and pagination – how to read page # from url

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter paamayim

    (@paamayim)

    Well I think I found

    global $page;

    inside the plugin 😐

    oneone11

    (@oneone11)

    I had to do this once.. the way I ended up doing it was by placing the following PHP code in my theme…

    //grab the URL into a string variable (i.e., "yoursite.com/page/2" )
    $strURL = $_SERVER['REQUEST_URI'];
    //array the elements in the string btwn "/" (i.e. [page], [2] )
    $arrVals = split("/",$strURL);
    //boolean var used to alert when the integer page var is next
    $intnextone = 0;
    //integer variable for pagenumber
    $intpagenum = 0;
    // loop through the array
    foreach ($arrVals as $value) {
    	if ($intnextone == 1){$intpagenum=$value;} // assign var
    	if ($value == "page") {$intnextone =1;} //next loop is int
    }

    $intpagenum is your page number variable.

    Hope that helps

    Thread Starter paamayim

    (@paamayim)

    Yeah that’s the hard code way. By the way I found the method above that is working because WordPress itself already parse the number from the url, I suppose.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Static page and pagination – how to read page # from url’ is closed to new replies.