Created
July 29, 2019 08:35
-
-
Save gaambo/a504c61c38d645b7efe5ea2f21e7a142 to your computer and use it in GitHub Desktop.
ACF Post Type location rule in block field groups
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
/** | |
* Sets the post id from an acf ajax request | |
* This is needed for the post_type location rule to work on block field groups | |
*/ | |
add_filter('acf/location/screen', function ($screen) { | |
$postID = get_the_ID(); | |
if (!$postID) { | |
$postID = $_REQUEST['post_id'] ?? false; | |
} | |
if ($postID && !$screen['post_id']) { | |
$screen['post_id'] = $postID; | |
} | |
return $screen; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment