Yeah please a working example of this would be great?!
I often have clients request a way to index all pages and post in WordPress alphabetically or in many cases for their products in when running woocommerce.
But any example would be great and I can take it from there :-)
I am sorry i took so long to reply here is the function for pagination using query count.
function pagInate()
{
//HERE WE QUERY THE COUNT VARIABLE VALUE FROM TH DATABASE//
$show = 10;
$count = 123;//A TEST RESULT REMOVE AND REPLACE WITH QUERY COUNT FOR PRODUCTION//
$limit = ($count / $show);
//echo $limit;
foreach (range(‘1’, ”.$limit.”) as $char)
{
//echo $limit;
print ‘‘ . $char . ‘ | ‘;
}
}//end function
//WE CALL THE FUNCTION//
echo pagInate();
Pass the value as GET in this way or you can use POST method to.
a href=”index.php?value= $char //Which in this case $char will return the values 1 through 12 for each new page to show the next 10 results. You will need to add either an isset($_POST or $_GET value to grab each passed $char.
And of course your query above this will be
$page = isset($_GET[‘value’];
LIMIT $page , 10 or $show either one as long as it is called before the query.
This may require some thought as to returning zero or a lessor value for $count result,, so you will need to add a condition that checks count for a value less than the $show of 10 and this will be something like–>
if $count <= $show; { query any results }else{ query the count and fetch the LIMIT data and Do foreach }
This is awesome! So simple, but such a good use of the range function.
Would be good for a glossary or huge list of items.
Nice script !
Add this and it becomes a nice $_Get[‘page’]‘ . $char . ‘
Sorry what do you mean can you give working example..
Yeah please a working example of this would be great?!
I often have clients request a way to index all pages and post in WordPress alphabetically or in many cases for their products in when running woocommerce.
But any example would be great and I can take it from there :-)
I am sorry i took so long to reply here is the function for pagination using query count.
function pagInate()
{
//HERE WE QUERY THE COUNT VARIABLE VALUE FROM TH DATABASE//
$show = 10;
$count = 123;//A TEST RESULT REMOVE AND REPLACE WITH QUERY COUNT FOR PRODUCTION//
$limit = ($count / $show);
//echo $limit;
foreach (range(‘1’, ”.$limit.”) as $char)
{
//echo $limit;
print ‘‘ . $char . ‘ | ‘;
}
}//end function
//WE CALL THE FUNCTION//
echo pagInate();
Pass the value as GET in this way or you can use POST method to.
a href=”index.php?value= $char //Which in this case $char will return the values 1 through 12 for each new page to show the next 10 results. You will need to add either an isset($_POST or $_GET value to grab each passed $char.
And of course your query above this will be
$page = isset($_GET[‘value’];
LIMIT $page , 10 or $show either one as long as it is called before the query.
This may require some thought as to returning zero or a lessor value for $count result,, so you will need to add a condition that checks count for a value less than the $show of 10 and this will be something like–>
if $count <= $show; { query any results }else{ query the count and fetch the LIMIT data and Do foreach }