Support

Account

Home Forums General Issues Add number to Post Object values Reply To: Add number to Post Object values

  • Thanks for your reply John.

    I would like to format and style the first 2 values differently from the rest.
    So the code would be something along the lines of:

    
    <?php
    $featured_posts = get_field('test_post_object');
    if( $featured_posts ): ?>
        <ul>
        <?php foreach( $featured_posts as $post ): 
            if (value == 1|2){ ?>
                <div class="bluebg">
                     <div class="section-inner">
                         <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        <?php the_post_thumbnail('medium'); ?>
                    </div>
                </div>
           <?php }  else { ?>
                 <div class="section-inner">
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    <?php the_post_thumbnail('medium'); ?>
                </div>
           <?php }  ?>
        <?php endforeach; ?>
    
    <?php endif; ?>      

    If this isn’t possible, I know I can achieve what I want using the repeater field, but this would be much simpler to use.
    Thanks for your help!