wordpress pagination get current page number from url

后端 未结 4 1895
醉酒成梦
醉酒成梦 2021-01-02 07:43

I need to extract the value of \"page\" i.e 5 from this url - http://snypher.local/photos/page/5 What should I do to extract it in Wordpress? I am not able to get it from th

4条回答
  •  鱼传尺愫
    2021-01-02 07:49

    function get_url_var($name)
    {
        $strURL = $_SERVER['REQUEST_URI'];
        $arrVals = explode("/",$strURL);
        $found = 0;
        foreach ($arrVals as $index => $value) 
        {
            if($value == $name) $found = $index;
        }
        $place = $found + 1;
        return $arrVals[$place];
    }
    
    $page = get_url_var('page');
    

    I have used this function to get the value of the variable page from the url.

提交回复
热议问题