A
A
Asya2020-06-08 20:06:45
WordPress
Asya, 2020-06-08 20:06:45

Display posts by custom field in WordPress (ACF plugin)?

Good time everyone.
Guys, help me find the error, please. The site has a slider, images are displayed using the fields of the ACF plugin. Everything is fine, but the first 10 posts are displayed in the slider by default. And I need to display posts in which the slider field is not empty (well, or the field in which there is an image). I feel like I'm missing something, but I don't see what yet.
5ede6ff2add4a498991963.jpeg

When I changed the code to display by tags (in the post where there is a slider, I added the slider tag), everything began to be displayed as it should. But that's not a solution. And add a slider to the post, and a tag (((

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Sedov, 2020-06-09
@Armida-od

Checking the field for emptiness, if not empty, we display the block

<?php if ( get_field('slider') ) : ?>
<div class="single-top-slider-armida">
</div>
<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question