ACF Include Post

Hi,

I’m trying to understand how to dynamically include a specific post in the Query block from an ACF Post Object field.

I have set up the Post Object fields on the page:

Now I go to Query, and select the Post 1 field (Ignore the group name, it isn’t a repeater this was me testing something else earlier)

image

It does nothing, and if I save the page like this and try to load the frontend of the site, I get a critical error.

I have tried returning both post object and post ID in ACF to see if that made any difference and it doesn’t.

image

This seems super confusing and I was expecting this just to work.

What am I doing wrong?

Thanks,

Phil

OK so I have found the issue here diving a little deeper, however definitely feel like this is not ideal.

When I select manually a post to include and inspect the generated query code, it has ‘post__in’ => array( postID ),

If you allow ‘Select Multiple Values’ in ACF (which I don’t actually want) it obviously returns the post IDs in that same format (within an array) and it works. If you don’t enable multiple values, which I don’t want to, it obviously only returns an ID, not an array, breaking how the query is set up and how the post__in query works.

@Louis would there be a way to check for single or multiple post ID’s and using an array or not? That way it works for everyone. I know this is probably quite tricky possibly but I do feel this could be improved to catch single IDs and insert to an array to prevent it breaking.

Thanks!
Phil

Hi @phil22,

Thanks for the details and checking this out.
You should be able to achieve this now with 1.2.8.7.

I would be grateful if you could let me know if this helps you on your side or if you still experience the same issue.

Cheers,

1 Like

Hi @Louis,

That is a ridiculously quick fix, I guess you already knew about this? haha.

I have just tested and works perfectly. Again, thank you so much for a new release already.

Mad impressed and grateful for your efforts!

Thanks,

1 Like

@Louis can we have this work also when we load the acf field from Options pages? (currently it returns null when set like that)