I had this code working as I needed it to…but now I need to add a post count where the “____” is, beside “posters”, so I can manipulate the css depending on how many posters are showing, for example:

or
or
, etc.

I believe this can be done with $post_count or $found_posts but I’m not sure where to place it and or where to move the posters div (ie: inside the loop?):

<div id="posters_ _ _ _">
    <?php 
        $movieNumber = 1;
        $today = date('Ymd');
        $posts = array (
            'post_type' => 'movie',
            'posts_per_page'   => -1,
        );
        $loop = new WP_Query( $posts );
        while ( $loop->have_posts() ) : $loop->the_post();
            $attachment_id=get_field('movie_poster',$post->post_id);
            $size = "poster"; // (thumbnail, medium, large, full or custom size) 
            $image = wp_get_attachment_image_src( $attachment_id, $size ); // url = $image[0], width = $image[1], height = $image[2];
            echo '<div class="poster"><a class="various" rel="movies" href="#fancy' . $movieNumber++ . '"><img src="' . $image[0] . '" /></a></div><!-- #poster -->';
        endwhile; 
    ?>
</div><!-- #posters -->

Read more here: Echo the number of posts being displayed


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , ,

Wordpress related questions and answers:

Leave A Response