Support

Account

Home Forums ACF PRO wp_qyery and Group fields

Solved

wp_qyery and Group fields

  • Hi,

    I would like to display a list of posts that contain a custom field value which is based inside a group field.
    I have a true/false switch that either returns a 1 or 0. It’s to determine if a post is set as ‘featured’ or not.

    At the moment it is display all posts.

    Any help would be most appreciated. Thanks

    Here is my code:

    		// WP_Query arguments
    		$args = array(
    			'post_type'      => array( 'post_type_listings' ),
    			'post_status'    => array( 'publish' ),	
    			'posts_per_page' => -1,
    			'meta_query'     => array(
    				'key'     => 'listing_featured_listing',
    				'value'   => 1,
    				'compare' => '=',
    			),		
    		);
  • Use "{$group_field_name}_{$sub_field_name}" as the meta key

  • Working code:

    		// WP_Query arguments
    		$args = array(
    			'post_type'      => array( 'post_type_listings' ),
    			'post_status'    => array( 'publish' ),	
    			'posts_per_page' => -1,
    
    			'meta_key' => 'listing_payment_options_listing_featured_listing',
    			'meta_value' => 1,	
    		);
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.