Support » Fixing WordPress » Conditional based on amount of post in cat

  • I am building a featured content gallery in my template which will be generated by a category like ‘slideshow-1’.

    I want to set up a conditional statement so in the case that I only have one post in the ‘slideshow-1’ category the template will then load just the featured image styled to look like a static version of the slider instead of the actual slider.

    something like
    if ( cat=’slideshow-1′ has more than one post){
    // show slider
    }
    else (cat=’slideshow-1′ has only one post) {
    // show static featured image and title excerpt.
    }

    My question is there a conditional for ‘more than 1 post in cat’ or ‘ ‘just one1 post in cat’?

    thanks!

Viewing 1 replies (of 1 total)
  • You could do something like this… (Where ‘1’ is the id of the category you are checking.

    $cat_count = get_category('1')->count;
    if( $cat_count == 1 ) {
       // DO STUFF
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Conditional based on amount of post in cat’ is closed to new replies.