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
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.
Found a nice solution and I'd like to share it here for I was looking for exactly the same thing!
http://wordpress.org/support/topic/get-current-page-number-for-paginated-posts
So it's like:
<?php echo '(Page '.$page.' of '.$numpages.')'; ?>
use get_query_var
example $page = get_query_var('paged');
in your case it's 5
its work fine i've tested on my current WP (version 3.5.1)
$current_page = max( 1, get_query_var('paged') );
$total_pages = $wp_query->max_num_pages;
echo 'Page '.$current_page.' of '.$total_pages;
Result = Page 3 of 51