Answer the question
In order to leave comments, you need to log in
How to hide a block if there are more than 3 entries?
Hello.
There is a block.
In which two arrays are displayed, one displays the entries attached to the "Curators" entry, and the latest entries "Upcoming events"
There is not much space for the block, and I came up with the idea to do such a thing.
So that if there are more than 3 curators, then the "Upcoming events" block will have to disappear.
How to make this?
-----
My code on curated block output
<div class="kuratori">
<?php
$posts = get_field('lektori');
if ($posts) { ?>
<h2>Кураторы</h2>
<?php foreach($posts as $post) { setup_postdata($post); ?>
<div class="meropriyatiya">
<?php
$params = array('post_status' => 'future','post__not_in' => array($post->ID),);$the_query = new WP_Query($params); ?>
<?php while ($the_query->have_posts() ) : $the_query->the_post(); ?>
Answer the question
In order to leave comments, you need to log in
You need to wrap the block of events in a condition. If I'm not mistaken it should be like this:
if (count($posts) < 3) {
// блок мероприятий
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question