Created
December 20, 2022 20:21
-
-
Save mager19/6f5b977e8dcc1a340729e19ea54ac4a9 to your computer and use it in GitHub Desktop.
Reverse query relationship acf field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//obtain pages or post who added a relationship item - Reverse relationship posts | |
$tasks = get_posts(array( | |
'post_type' => 'task', | |
'meta_query' => array( | |
array( | |
'key' => 'task_parents', // name of custom field | |
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234" | |
'compare' => 'LIKE' | |
) | |
) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment