Support

Account

Home Forums ACF PRO Reverse query on author.php from User Relationship field Reply To: Reverse query on author.php from User Relationship field

  • Hi @claytoncollie

    That’s weird. Your code looks OK for me. Could you please try to add the ID manually and change the compare option? You can try the following codes:

    $items = get_posts(array(
    	'post_type' => 'attorney',
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		array(
    			'key' => 'vbmmp_attorney_related_user_profile', // name of custom field
    			'value' => '"123"', // matches exaclty "123", not just 123. This prevents a match for "1234"
    			'compare' => 'LIKE'
    		)
    	)
    ));
    $items = get_posts(array(
    	'post_type' => 'attorney',
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		array(
    			'key' => 'vbmmp_attorney_related_user_profile', // name of custom field
    			'value' => '123', // matches exaclty "123", not just 123. This prevents a match for "1234"
    			'compare' => '='
    		)
    	)
    ));
    $items = get_posts(array(
    	'post_type' => 'attorney',
    	'posts_per_page' => -1,
    	'meta_key' => 'vbmmp_attorney_related_user_profile',
    	'meta_value' => '123',
    	'meta_compare' => '=',
    ));

    You can also try to get the post based on another custom field to check it up. To learn more about the custom field query, please take a look at this page: https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters.

    I hope this helps.