Answer the question
In order to leave comments, you need to log in
How to show posts by checkbox condition in wordpress?
Colleagues, good afternoon! The essence of the problem is displaying a preview of a certain post (marked with a checkbox in the admin panel) in a custom wordpress page template. The Advanced Custom Fields plugin was installed, a field of type true/false was created in the form of a checkbox "display on the main page". I post the following code
<?php $posts = get_posts ("category=27&orderby=date&numberposts=10"); ?>
<?php if ($posts) : ?>
<?php foreach ($posts as $post) : setup_postdata ($post); ?>
<li class="inner-news__item">
<div class="inner-news__item-wrap">
<a href="<?php the_permalink() ?>" rel="bookmark"><span class="inner-news__item-title"><?php the_title(); ?></span></a>
<?php the_excerpt(); ?>
</div>
<div class="inner-news__item-img">
<?php the_post_thumbnail();?>
</div>
</li>
<?php endforeach; ?>
<?php endif; ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question