Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Here are some post count variables you can use in your theme template files:

    // count for total found posts on the current (query) page.
    $current_page_post_count = $wp_query->post_count;
    echo 'there are ' . $current_page_post_count . ' posts on this page';
    
    // count for total found posts for the current query
    $current_query_total_post_count = $wp_query->found_posts;
    echo 'there are ' . $current_query_total_post_count . ' posts in total for this query';
    
    // current post number inside the loop
    // (starts with 0)
    $current_post_in_loop = $wp_query->current_post;
    echo 'this is post number' . $wp_query->current_post; 
    
    // count of all posts published, regardless of current query
    $count_posts = wp_count_posts();
    echo 'total posts = ' . $count_posts->publish;
    
    // max post setting on wp-admin > Settings > Reading
    $default_posts_per_page = get_option('posts_per_page');
    echo 'default posts_per_page = '. $default_posts_per_page;

    Thread Starter saravanan

    (@saravananc)

    thanks..

    Moderator keesiemeijer

    (@keesiemeijer)

    No problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘post per page’ is closed to new replies.