WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to retrieve the default value of Post per page (the value that is set in settings->reading.

I've looked around and so far I've only found ways to query it. problem is i dont want to change what was set i just want to retrieve it for pagination purposes. i thought of using $something->post_count.(i might be wrong but as i understand it returns the amount of posts displayed currently) but this could be wrong in some cases.

Also how can i get the total number of posts ?

share|improve this question
up vote 9 down vote accepted

It's saved in an option:

$default_posts_per_page = get_option( 'posts_per_page' );

Reference: get_option Parameters

You can see the keys and values of all available options by manually entering the admin url:



Total number of posts:

global $wp_query;
$total_posts = $wp_query->post_count;
share|improve this answer
thank you very much milo i was looking for it entirely in the wrong place.. How do i get the total number of posts though ? Post count is not just for current page ? – Yaniv Kossas Jan 13 '13 at 19:19
@YanivKossas - sorry, missed that part of the question, Chip has edited the answer in there. – Milo Jan 13 '13 at 19:23
post_count however returns the number of posts currently displayed that mean if you have posts_per_page set to 3 and you have 40 post it will return - 3 however if you have lets say 5 posts and you are on page 2 it will return 2 if that makes sense - it doesn't return the total number of posts – Yaniv Kossas Jan 13 '13 at 19:25
if you want total number of posts for a query use $wp_query->found_posts. You can determine the remainder on the last page with found_posts and $wp_query->max_num_pages – Milo Jan 13 '13 at 19:28
Milo and Chip Thanks you very much. – Yaniv Kossas Jan 13 '13 at 19:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.