I'm using WordPress to display some posts in a table and I have a pagination along with this. The table contains a column named "Number" and a column for post title. My problem is that I don't know how to number every post when I'm on the next page because the number of post starts all over instead of the count where remained. How would I resolve this?
The count it doesn't start from where it should when I go to the next page. My code:
<?php
require('wp-load.php');
if ( is_user_logged_in() ) {
global $wp_query;
$paged = (isset($_GET['pagina'])) ? $_GET['pagina'] : 1;
$args = array(
'posts_per_page' => 2,
'paged' => $paged,
'post_type' => 'post'
);
$the_query = new WP_Query( $args );
echo '<table>';
$count = $paged - 1;
echo '<tr>
<td width="100">Number</td>
<td width="200">Title</td>
<tr>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$count++;
//var_dump($count);
echo '<tr>';
echo '<td>'.$count .'</td>';
echo '<td>'.the_title().'</td>';
echo '</tr>';
}
echo '</table>';
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'format' => '?pagina=%#%',
'current' => max( 1, $paged ),
'total' => $the_query->max_num_pages,
'prev_next' => True,
'prev_text' => __('Previous'),
'next_text' => __('Next'),
) );
}
?>
</div>