How to display posts with plugin (advanced custom fields) field groups?

Question

I have a php/wordpress code (present inside abc.php file) as shown below which displays images of particular size.

php/wordpress:

<ul id="list-thumbs" class="list-grid">
    <?php
    while ( have_posts() ) : the_post();
        ?>
        <li class="list-grid__thumb shows-grid__item">
                    <a class="list-grid__img-link" href="<?php echo esc_url( get_the_permalink() ); ?>" tabindex="0">
                        <?php if ( has_post_thumbnail() ) { ?>
                            <?php
                            $image_id = get_post_thumbnail_id( get_the_ID() );
                            WORLDImagesthe_img_fit_figure( $image_id, 'list-grid__image', '(min-width: 450px) 50vw, 70vw', false ); ?>
                        <?php } ?>
                    </a>

        </li>
    <?php endwhile; ?>
</ul>

The code above displays around 30-40 images from top to bottom with 4 images in one row.

(a) All of those images are featured image in wordpress associated with a post.

(b) Every post has two fields, Row View (in_row_view) and Column View (in_column_view) coming from Advanced Custom Fields plug in. I am not sure if we can call those two fields as custom fields.

(c) Row View and Column View both are switch which can be enabled to Yes or No. By default it is set to No.

(d) For Row View, I am using:

if(get_field('in_row_view' ) == '1'){   }

For Column View, I am using:

if( get_field('in_column_view' ) == '1'){   }

What I want to achieve is I want to display those posts which have Row View switch enabled to Yes.

Problem Statement:

I am wondering what changes I need to make in the php/wordpress code above so that it displays only those posts which have Row View switch enabled to Yes.

Probably I need to integrate this code if(get_field('in_row_view' ) == '1'){ } in the php/wordpress code above.

0
user5447339 3 months 0 Answers 21 views 0

Leave an answer