How to filter get_post with ACF by a checkbox field?

So, the scattered documentation on this is really less than clear. For checking for unchecked posts added the following meta_query: ‘meta_query’ => array(array( ‘key’ => ‘external’, ‘value’ => ‘0’, ‘compare’ => ‘=’ )) For filtering by checked it was just this: meta_query => array(array( ‘key’ => ‘external’, ‘value’ => ‘0’, ‘compare’ => ‘=’ ))

change value of fields created with advanced custom fields in the front

If you want to include your own inputs on the acf_form() you should use some of its parameters to allow the form submit them. Otherwise your inputs will be out of the form. As an example you could use this code: <?php acf_form( array( ‘html_after_fields’ => ‘<input type=”text” id=”id_whatsapp” name=”acf[n_whatsapp]” value=”acf[n_whatsapp]”>’, ) ); ?> You … Read more

ACF: How to make get_field() ignore the main wp query?

I resolved this by adding wp_query->is_main_query() to my clauses before I set the query update. Ie… // The filter code that shows only the current authors posts add_action(‘pre_get_posts’, ‘query_set_only_author’); function query_set_only_author( $wp_query ) { if( is_admin() && get_current_user_role()==”required_role” && $wp_query->is_main_query() ) { if ( basename($_SERVER[‘PHP_SELF’])==”edit.php”){ $wp_query->set( ‘author’, $current_user->ID ); } }

get all posts in custom post type by ACF field value

Meta Queries are nested arrays. See the WP_Query section on meta queries. Option 1 Use meta_key and meta_value directly in the query arguments, not as a meta query. $student_query_args = [ ‘post_type’ => ‘student_list’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 100, ‘order’ => ‘DESC’, ‘meta_key’ => ‘program_id’, ‘meta_value’ => 5317, ]; Option 2 The meta query … Read more