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 a post type slider, when you have more than one post to display navigation.

My code:


$count_slider = wp_count_posts('slider');
echo $count_slider->publish; 


<?php if($count_slider > 1): ?>

<div id="slideshowcontrol" class="clearfix">
<div id="button_prev"><a href="#" id="slideshowprev"><img src="x.gif" alt="Prev" /></a></div>
<div id="button_next"><a href="#" id="x.gif" alt="Next" /></a></div>

<?php endif; ?>

But it doesn’t work. Why?

share|improve this question
up vote 0 down vote accepted

This is a basic PHP error, you need to turn on debugging.

$count_slider is an Object and not an Integer which is what you are checking for, since you seem to want to compare published posts anyhow , write it like:

<?php if($count_slider->publish > 1)
share|improve this answer
Thanks so much,worked! – Dima Botezatu Aug 11 '13 at 7:02
Please mark the question an answered. – Wyck Aug 11 '13 at 11:23

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.