• Resolved YouKnowItMedia

    (@youknowitmedia)


    ok so I’m trying to tweak a parameter in my loop, here is the loop which works fine:

    <?php /* Start the Loop */ ?>
        <?php $count = 0; $output = min(0, $wp_query->post_count-1); ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'loop', get_post_format() ); ?>
                    <?php if ($count == $output) : ?>
                          <?php if (($wp_query->post_count) <= 0) : ?>
                                  <div class="posts_0_area_spacer">
                                  </div>
                          <?php endif; ?>
                          <?php if (($wp_query->post_count) <= 1) : ?>
                                  <div class="posts_1_area_spacer">
                                  </div>
                          <?php endif; ?>
                          <?php if (($wp_query->post_count) <= 2) : ?>
                                  <div class="posts_2_area_spacer">
                                  </div>
                          <?php endif; ?>
                          <?php if (($wp_query->post_count) <= 3) : ?>
                                  <div class="posts_3_area_spacer">
                                  </div>
                          <?php endif; ?>
            <?php endif; ?>
        <?php $count++; ?>
    <?php endwhile; ?>

    I want to tweak the ($wp_query->post_count) <= X) lines so that its just “equal to” so its not “less than or equal to” but when I remove the “<” it breaks everything, telling me there is an unexpected “=” on that line, seems odd to me that this doesn’t work?? Someone please help me out. The goal of this code in the loop is to show different divs after the posts depending on the number of posts.

    please put backticks around your code in the future – mod

Viewing 2 replies - 1 through 2 (of 2 total)
  • After removing the < are you using just = or == ? Single = is an assignment operator, not the same as == which is a comparison operator. See this for more info.

    Thread Starter YouKnowItMedia

    (@youknowitmedia)

    Thanks so much this does fix my problem!

    The last issue I’m having to get it to work perfectly is something to tell it to show these divs after all the posts on the screen no matter how many they are.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘"$wp_query->post_count" not working when tweaked’ is closed to new replies.