Now I want to extend this query to directly load all relations I have instead of having to iterate over all posts and make queries for custom fields one by one (via get_field). Can I somehow tell wordpress to join the custom fields into my query automatically at once?
This isn’t part of what you asked, but You can use -1 for posts_per_page to tell WP to get all of the posts
<code>posts_per_page</code> => -1,
But as far as your real question goes, no. WP_Query is not capable of doing joins to other posts through a custom field. For something like this you would need to write your own SQL query and use https://codex.wordpress.org/Class_Reference/wpdb and then write your own code to loop over and display the results.
Viewing 2 posts - 1 through 2 (of 2 total)
The topic ‘Join posts with fields in single query’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users