How do I pass additional parameter in the url for pagination to work
my existing page link is http://localhost/site/wp-admin/admin.php?page=myPage
How do I create the syntax / logic in PHP to add &pagenum=1
in the url?
currently I have this code
global $wpdb;
$per_page = 6;
$page_query = $wpdb->get_var("SELECT COUNT('id') FROM form");
$pages = ceil($page_query / $per_page);
$currentPage = (isset ($_GET['pagenum'])) ? (int)$_GET['pagenum'] : 1;
$start = ($currentPage -1 ) * $per_page;
$row = $wpdb->get_results("SELECT * FROM form LIMIT $start , $per_page");
//foreach loop here
There is a wordpress function for adding
$_GET
-Params to an URL: add_query_arg(). It works like this:By default it adds the param to the current page (gets content from
$_SERVER[REQUEST_URI]
) but you can also pass an optional param to the function if you want the link to go to another page: