Answer the question
In order to leave comments, you need to log in
Output posts on the main, if you check the box?
Please tell me how to implement.
How to make it so that only those posts that have a checkmark created through free fields (ACF) are displayed.
That is, when outputting, check for the presence of a value in an arbitrary field.
Answer the question
In order to leave comments, you need to log in
channels.getParticipants
Then you save the users of this channel in the database and when the user works with your bot, run into this database with the user ID and check if it is there or not.
Create a field, display it for posts.
In the loop, place the condition if there is a check mark, output. Everything.
<?php $loop = new WP_Query( array('post_type' => 'post','posts_per_page' => -1,'order' => 'ASC',));
while ( $loop->have_posts() ): $loop->the_post(); ?>
<?php if (get_field('name_field') == 'yes'): ?>
// echo
<?php endif ?>
<?php endwhile; wp_reset_postdata(); ?>
https://wp-kama.ru/hook/pre_get_posts
add_action( 'pre_get_posts', 'include_posts_by_meta' );
function include_posts_by_meta( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
// ... Изменяем критерии выборкии для постов на главной странице
$query->set( 'meta_query', /* ... */ ); // Смотри параметры WP_Query https://wp-kama.ru/function/WP_Query#meta_query
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question