When choosing from a Post Object select2 dropdown, and encountering multiple posts with the same title, the Post ID is provided in parentheses – as in the attached image (for a Custom Post Type named “City”).
It’s better to get the Post ID than not to get any clues at all for disambiguation, but what would be more helpful for us, and I suspect others, would be terms – in this case custom taxonomy terms (state, country…), though post meta might do in a pinch.
I’ve looked at both PHP and JS API select2 filters, and none seems to have any effect (or even to be fired) when making such a selection, and I have yet to figure where the Post ID comes from at all, which would be a first step toward substituting some else more useful for it.
Thanks for your reply, but I see now that the the post ID in parentheses may be added by a different plugin, Admin Columns Pro (AC), which among other things provides its own ACF integration.
AC apparently intercepts the post list before the ACF Post Object select2 field processes the list of posts. Where the same ACF field appears by itself – outside of an admin column – the post IDs do not appear. I expect that that list will be modifiable via the ACF hook you specify. To modify the one that appears in the admin column setting, it looks like I’ll have to kludge something up. On the bright side, an AC “get_duplicates” function and its application look like useful models for dealing with ACF post-list output.
I still haven’t found exactly where or how the substitution occurs. If and when I do, I’ll post the information here, just so that ACF users can get something out of this thread, which otherwise I’d see about getting deleted.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users