• My main page displays all the posts as thumbnails inside a javascript slider. I’ve set up the slider to include 6 thumbnails per slide and i’ve used the following to display them:
    `<?php
    global $post;
    $today = get_posts(‘numberposts=6&category_name=’.$currentday);
    foreach($today as $post) :
    setup_postdata($post);
    ?>
    <?php the_post_thumbnail(); ?>
    <?php endforeach; ?>`

    (my main page only displays posts with a category name the same as the current day)

    From there what I have done is added an additional slide and did the same code but offset the posts by 6 so I could fill the next slide. Then the third slide offset by 12 and so on and so forth.

    The problem is the amount of posts will really fluctuate, so rather than adding additional slides I want wordpress to know how many posts there are and add or remove slides accordingly.

    So somehow do:
    if post count is equal to or less than 6 show one slide.
    if post count is more than 6 but equal to or less than 12 show two slides.
    if post count is more than 12 but less than or equal to 18 show three slides.
    and so on.

    Not even sure if I am going about this right way, any help would be appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘If category has x number of posts..’ is closed to new replies.