Skip to content

Instantly share code, notes, and snippets.

@rob-gordon
Created May 17, 2017 14:32
Show Gist options
  • Select an option

  • Save rob-gordon/eafb6ae8c7cd5428298c186263db1890 to your computer and use it in GitHub Desktop.

Select an option

Save rob-gordon/eafb6ae8c7cd5428298c186263db1890 to your computer and use it in GitHub Desktop.
Confusing WP Query's with ACF
# Querying a relationship field (stored as a serialized array)
# https://www.advancedcustomfields.com/resources/querying-relationship-fields/
$related_posts = get_posts([
'post_type' => ['publication'],
'posts_per_page' => 6,
'meta_query' => [
[
'key' => 'related_research_area',
'value' => $cur_id,
'compare' => 'LIKE'
]
]
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment