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 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.