Support

Account

Home Forums General Issues How to Query CPT by Relationship Field Reply To: How to Query CPT by Relationship Field

  • If I remove the meta_query portion of the $args (see below), I get all the post.

    
                                          $args = array(
    						'numberposts'	=> -1,
    						'post_type'		=> 'listing',
    					);
    
    					$agentsListings = new WP_Query( $args );
    

    But this won’t work because I need to pull the posts per agent (something like code below). I am doing some something wrong with the meta_query portion of my query. Please help!

    	$args = array(
    						'numberposts'	=> -1,
    						'post_type'		=> 'listing',
    						'meta_query' => array(
    							array(
    								'key' => 'your_agent',
    								'value' => '"' . $post->ID . '"',
    								'compare' => 'LIKE'
    							)
    						) 
    					);
    
    					$agentsListings = new WP_Query( $args );