Created
November 14, 2016 10:08
-
-
Save tormjens/5fdcb09bc9f1da1b56937260aecab3bc to your computer and use it in GitHub Desktop.
Add Post Type Templates (WordPress 4.7) To ACF Add Field Group
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
<?php | |
add_filter('acf/location/rule_values/page_template', function($val) { | |
$post_types = get_post_types(array('public' => true), 'objects'); | |
$new_values = array(); | |
foreach($post_types as $post_type) { | |
$values = array(); | |
$items = get_page_templates( null, $post_type->name ); | |
foreach($items as $name => $item) { | |
$values[$item] = $name; | |
} | |
$new_values[$post_type->label] = $values; | |
} | |
return $new_values; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment