Pagination and Set Current Page Link
-
Hey All –
I am struggling with something that seams like it should be very easy – and is not. I a using a plugin for pagination (wp_paginate) and when I add it, it shows the pagination links and does not advance the active page marker in the pagination nav or the posts. So for all pages it shows page 1.
I found some code to add the current URL to the end of the page and get it to work, but it seems like a long way to go for getting and appending the page number to the post.
Here is the function I am using in functions.php:
function get_current_page() { $pageURL = 'http'; //check what if its secure or not if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } //add the protocol $pageURL .= "://"; //check what port we are on if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } //cut off everything on the URL except the last 3 characters $urlEnd = substr($pageURL, -3); //strip off the two forward shashes $page = str_replace("/", "", $urlEnd); //return just the number return $page; }
And here is what I am using on the page to display the link:
query_posts('cat=4&paged='.get_current_page());
If anyone has an idea on how to easily get the page number without using the function I listed above or how this could be easier – please-o-please let me know!
Thanks in Advance!
Chris
- The topic ‘Pagination and Set Current Page Link’ is closed to new replies.