On Cats Who Code, I shown you how to integrate a pagination on your theme. That’s a nice trick, but if you styled it with css and have less than 11 posts published, it will only display a blank container. Let’s fix it.
On Cats Who Code, I shown you how to integrate a pagination on your theme. That’s a nice trick, but if you styled it with css and have less than 11 posts published, it will only display a blank container. Let’s fix it.
To achieve this recipe, we're going to use a cool new function, introduced in WordPress 2.7, and called wp_count_posts().
Paste the following code anywhere on your template:
<?php
$count_posts = wp_count_posts();
if ($count_posts->publish > 10) {
//Your code to be displayed only if more than ten posts have been published
}
?>
That's all. Note that you'll need to replace 10 by the number of posts which are displayed at the same time on your homepage.
6 Responses
Well, simple but really useful. Thanks!
Nice, I can imagine this also being useful for starting-up blogs- for example wrapped around a set of post stats that only appear when there have been a decent amount of posts to warrant showing the information.
Let’s me test it
thanks
I suggest to take a look even at http://www.themeshaper.com/thematic/ to achieve a similar result. do you know the power of wordpress frameworks and child themes???
First create query(test).
SELECT *
FROM post
WHERE POST LIKE
ORDER BY ID
then:
#TEST.POST#
Try to experiment.
Trackbacks: