php - How to create a loop in Wordpress to display and filtratsii records?

823

I created a custom field True / False (checkbox analogue) by means of Advanced Custom Fields plugin. If a check mark in the box is, the record should fall on the main page in the slider. If there is no check mark, respectively, in the slider on the home this record misses.

If the box is checked, the value is recorded in the field - the "1" unless there is "0".

I created this query:

<? $query1 = new WP_Query('posts_per_page=5&meta_key=go_to_main&meta_value_num=1&orderby=modified&order=DESC');?>
<? while( $query1->have_posts() ) : $query1->the_post(); ?>
<a href="<? the_permalink(); ?>"><? the_title(); ?> (Значение чекбокса - <? the_field('go_to_main') ?>)</a>
<? endwhile; wp_reset_postdata(); ?>

But why is this cycle displays all the records that have ever put a tick. That is to say, I put a tick, and this cycle brings a record, and then remove the check mark, but the record is still displayed. One gets the impression that the script simply does not see the line:

meta_value_num=1

Please tell me how to solve the problem.

People are also looking for solutions to the problem: php - Unable to reference cookie value in htaccess with %1

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.