Created
February 18, 2015 10:34
-
-
Save paulmist/50419d98643a52c8a65d to your computer and use it in GitHub Desktop.
ACF - Dynamically populate selected entries in Relationship field
This file contains hidden or 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
add_filter('acf/load_value/name=name-of-relationship-field', function($value) { | |
if(empty($value)) { | |
$value = get_posts(array( | |
'post_type' => 'name-of-post-type', | |
'posts_per_page' => -1, | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'fields' => 'ids', | |
)); | |
} | |
return $value; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment