S
S
Suil2020-02-20 16:13:29
PHP
Suil, 2020-02-20 16:13:29

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.

5e4e85e0c24a8971627108.jpeg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kafkiansky, 2019-06-23
@mad_maximus

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.

L
Lord_Dantes, 2020-02-20
@Suil

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(); ?>

A
Alex, 2020-02-20
@Kozack

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 question

Ask a Question

731 491 924 answers to any question