Created
October 5, 2021 13:28
-
-
Save codente/8053c712c95ff205b65aa66d9de78697 to your computer and use it in GitHub Desktop.
bb-pre-populate page with template
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
| // Uses the add_meta_boxes_{post_type} hook for given post type | |
| // change page in hook to your post type where you want this to happen | |
| add_action( 'add_meta_boxes_page', 'page_default_content' ); | |
| function page_default_content( WP_Post $page ) { | |
| // Add the meta data fields you want the custom post type to grab | |
| $page_meta_data = [ | |
| '_fl_builder_enabled', | |
| '_fl_builder_data_settings', | |
| '_fl_builder_draft_settings', | |
| '_fl_builder_draft', | |
| '_fl_builder_data' | |
| ]; | |
| foreach ( $page_meta_data as $meta ) { | |
| // Using a 'template' with ID of 17 | |
| $data = get_post_meta( 17, $meta, true ); | |
| add_post_meta( $page->ID, $meta, $data ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment