Support

Account

Home Forums Front-end Issues Counting $post_objects

Solving

Counting $post_objects

  • Hi,

    I’m trying to count the number of output post objects in order to use the correct sized div, but this only works as far as ‘2’.

    Has anyone delt with this before?

    <?php $post_objects = get_field('liveaboard_destinations');
    if( $post_objects ): ?>
    
    <?php foreach( $post_objects as $post):?>
    <?php setup_postdata($post); ?>
    										<?php $count = count( $post_objects );											if ( $count < 2 ) { ?>
    												<div class="col-md-12 destinations">
    																						<?php } elseif ( $count = 2 ) {  ;?>
    																							<div class="col-md-6 destinations">
    																						<?php } elseif ( $count = 3 ) { ?>
    																							<div class="col-md-4 destinations">
    																						<?php } ;?>
  • Download & Open /includes/functions/general.php
    REMOVE the final ?>
    Upload the amended file.
    And: http://bit.ly/1cyIhDI
    etui sony xperia e3
    etui galaxy A5

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

The topic ‘Counting $post_objects’ is closed to new replies.