Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a post type slider, when you have more than one post to display navigation.

My code:

<?php

$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>
</div>

<?php endif; ?>

But it doesn’t work. Why?

share|improve this question

1 Answer 1

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

 
discard

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.