Get post using meta key

PHOTO EMBED

Thu May 19 2022 08:04:13 GMT+0000 (UTC)

Saved by @ali_naqvi #html #wordpress

<div class="posts">
            <h2 class="mb-40">
                Recommended Powerlister
            </h2>

            <?php

            $query_args = array(
                'post_type' => 'post',
                'posts_per_page' => 4,
                'meta_key'        => 'show_in_recommended',
                'meta_value'    => '1',
                'orderby'     => 'modified',
                'order'       => 'DESC',
            );

            // The Query
            $the_query = new WP_Query($query_args);

            // The Loop
            if ($the_query->have_posts()) {
                while ($the_query->have_posts()) {

                    $the_query->the_post();
                    $recommended = get_field('show_in_recommended', get_the_ID());



                    $photo = get_field('photo', get_the_ID());
                    $company = get_field('company', get_the_ID());

            ?>

                    <div class="card" style="text-align:left;padding: 0px;width: 100%; margin-left: 4px;">
                        <img src="<?php echo esc_url($photo['url']); ?>" class="card-img-top" alt="...">
                        <div class="card-body">
                            <h2 class="card-title"> <?php the_title(); ?></h2>
                            <p style="font-size: 14px;margin-bottom:0;font-weight: 300;"><?php echo $company; ?></p>
                            <p class="card-text" style="color:#AFAFAF;margin-bottom:0;"><?php echo get_the_date(); ?></p>
                            <a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/arow.png" alt=""></a>
                        </div>
                    </div>
                    <hr>

            <?php

                }
                /* Restore original Post Data */
                wp_reset_postdata();
            } else {
                // no posts found
            }

            ?>



        </div>
content_copyCOPY