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.


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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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