I am using the Advanced Custom Field Plugin to create references from one custom object to multiple instances of another.
The plugin stores the multiple references as an array. So for example my post refers to posts 6,17 and 345, the meta value stored is "6,17,345".
I am trying to query for a particular post all references to it. I have seen some references to the same problem in this forum. see e.g. here.
That would suggest :
$posts = get_posts(array( 'numberposts' => -1, 'post_type' => 'link', 'meta_query' => array( array( 'key' => 'related_to', 'value' => get_the_ID(), 'compare' => 'LIKE' ) ) ));
However this is not correct as the following example demonstrates: if the id of the post was '45' it would return the reference above that contains '345', but not '45'.
In native SQL i could write up a regular expression to do the right thing - what is the right "wordpress" way to get the results I want - just write a custom query ?