Viewing 1 replies (of 1 total)
  • Plugin Contributor Patrick Jackson

    (@pjackson1972)

    Hi Diego_circo,

    This isn’t part of the plugin’s API, so I can’t guarantee that this will still be available in future versions of the plugin, but the WP_Query object is available in the template as $ic_posts.

    So $ic_posts->post_count will give you the total number of posts being listed.

    If you want the current post number, use $ic_posts->current_post. Note that it starts counting at zero, so you may want to add 1 to it.

    If you added the following to the top of your custom post_loop_template.php file (right under <div class=”post hentry ivycat-post”>)…

    <!-- This will output the post number and total posts  -->
    <div class="post-count">
        <p><?php  echo $ic_posts->current_post + 1; ?> of <?php  echo $ic_posts->post_count; ?> posts</p>
    </div>

    … and you were listing, say, 3 posts; you would get something that looked like…

    1 of 3 posts
    … (post 1 content) …

    2 of 3 posts
    … (post 2 content) …

    3 of 3 posts
    … (post 3 content) …

    You can check out more Methods and Properties of the $ic_posts (WP_Query) object in the codex:

    https://codex.www.ads-software.com/Class_Reference/WP_Query#Properties

    Note that it’s called $the_query in their examples.

Viewing 1 replies (of 1 total)
  • The topic ‘Count posts’ is closed to new replies.