12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- function acf_get_post_templates() {
-
- $cache = acf_get_data( 'post_templates' );
- if ( $cache !== null ) {
- return $cache;
- }
-
- $post_templates = array();
- $post_templates['page'] = array();
-
- if ( method_exists( 'WP_Theme', 'get_page_templates' ) ) {
- $post_types = get_post_types();
- foreach ( $post_types as $post_type ) {
- $templates = wp_get_theme()->get_page_templates( null, $post_type );
- if ( $templates ) {
- $post_templates[ $post_type ] = $templates;
- }
- }
- }
-
- acf_set_data( 'post_templates', $post_templates );
-
- return $post_templates;
- }
|