• 
    <?php 
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    echo $paged.' of '.$wp_query->max_num_pages; 
    
    ?> </li>
    <li> <?php next_post_link(); ?></li>
    <li> <?php previous_post_link(); ?> </li>
    

    Here is my code but it is showing only — 1 0f 0 —I wanted the first number to change each time I click the next or previous link. Can someone give some help? Please

    • This topic was modified 7 years, 6 months ago by Jan Dembowski.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The first part of the code given counts the number of posts in the current loop and sets up the pagination.

    When using single.php, there is only 1 post, the post you are outputting using single.php and there are no ‘pages’. Hence 1 of 0.

    Each time you use the prev or next links and load another single post, it re-loads single.php.

    The premise is the issue.

    Thread Starter fernando1984

    (@fernando1984)

    Yes I know when when using the prev or next links it might load one at a time. But also passing the parameter True to the prev and next link it will result to go through each post from it’s same category. So is there a way to count the position from that category’s post as 1 0f 4, and determine the value of total of posts and current one?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I need to show page x of y in single.php’ is closed to new replies.