Still useful after 4.7, but needs additional hook
-
We ran into an issue with our Cornerstone page builder because it validates saving the post type based on what is declared to be available. This caused saving to fail.
Sometimes you want to use the page templates of your theme with your own custom post types it’s not aware of. To declare support for those types we can do something like this:
$post_types = array('my_custom_post_type'); // populate from settings foreach ($post_types as $post_type) { add_filter("theme_$post_type_templates", 'add_page_templates_to_cpt' ); } function add_page_templates_to_cpt( $post_templates ) { $page_templates = wp_get_theme()->get_page_templates( null, 'page' ); return array_unique( array_merge( $post_templates, $page_templates) ); }
Would be great if this could be included as part of the plugin. Thanks!
- The topic ‘Still useful after 4.7, but needs additional hook’ is closed to new replies.