any ACF function beginning with “the_” echoes out the result. Replace it with “get_” and it will instead return the result.
That’s why you’re seeing the ID echoed on the page but not applied to your query.
So do this:
query_posts(array( 'cat' => get_sub_field('part_category'), // get posts by category id 'posts_per_page' => -1 // all posts )); ?>
and it should work better.
I do feel the need to inform you that using query_posts is a nono in the WP developer community since quite some time. If you’re looking to alter a core query you should take a look at the pre_get_posts filter: https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
and If you’re looking to create a whole new set of posts you should look at wp_query: codex.wordpress.org/Class_Reference/WP_Query
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!