WP_Query custom field pass the post id

1st query: $exclude_post_top_stories=””; // WP_Query arguments $args = array ( ‘post_status’ => array( ‘publish’ ), ‘posts_per_page’ => ‘-1’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ); // The Query $exclude_query = new WP_Query( $args ); // The Loop if ( $exclude_query->have_posts() ) { while ( $exclude_query->have_posts() ) { $exclude_query->the_post(); // do something $exclude_post_top_stories[] = get_the_id(); } … Read more

wpdb and acf via wp rest api

I ended up using $wpdb for my custom tables and went with wp_query for my custom posts with ACF fields $q = new WP_Query(array( ‘post_type’ => ‘coupon’, ‘post__in’ => $cids )); $coupons = array(); while($q->have_posts()) : $q->the_post(); $p = get_post(); $f = get_fields(); $m = array_merge((array)$p, (array)$f); array_push($coupons, $m); endwhile; And that’s how the cookie … Read more

ACF Relationship – Exclude pages not created by author

If you want to exclude ALL pages that doese’t have ‘collaborator’ set as author, then you want to exclude all other pages in the site and include all pages of that author minus, maybe, some hand picked pages of that author, then I think you can use this: add_filter(‘acf/fields/relationship/query/name=products’, ‘exclude_id’, 10, 3); function exclude_id ( … Read more

How can you query posts by advance custom field when the value is a serialized array? [closed]

I would advise using the built-in ACF functions for this. Elliot has provided a full toolbox for you and documentation for all field types: <?php // Conditional statement (Single Value) if(get_field(‘page_layout’) == “col_1”) { //… } //Conditional statement (Multiple Values) if( in_array( ‘col_1’, get_field(‘page_layout’) ) ) { //… } ?> Check out the ACF documentation: … Read more