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 ?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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:
/wp-admin/options.php
Edit
Total number of posts:
global $wp_query; $total_posts = $wp_query->post_count;
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0