WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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 have the following code, Assume this code spits back one post. the page displaying that post will also display pagination. Why? It shouldn't. This code only queries for posts that belong to the post type of post.

    protected function _general_wordpress_loop(){

                    echo $this->_options['post_before'];




                    echo $this->_options['post_after'];



A quick run down, we query the post type of post, state if we have more posts, while we have more posts display the post, after the while, display the pagination (if there is a wrap (divs) wrap the nav, else display as normal). If there are no posts, display a custom error page.

Pretty basic and simple stuff. How ever I am getting pagination for things like, the category test has one post and I can see pagination.

is there a way to say "if you have more then one post display this?" I know if(have_posts()){} will do what ever assuming it has more then 0 posts which means pagination will be displayed by that logic.

share|improve this question
up vote 0 down vote accepted

post_count property of query object will hold amount of posts queried.

Note that this is not often used and it is more common to display such elements by conditional logic (is_singular(), is_archive(), etc) or on template level.

PS query_posts() is evil and should not be used

share|improve this answer
Need better explanation on why not to use query posts. – TheWebs Jun 18 '13 at 18:15
@TheWebs here you go :) wordpress.stackexchange.com/a/1755/847 – Rarst Jun 18 '13 at 18:16

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.