Last active
          June 19, 2024 21:30 
        
      - 
      
 - 
        
Save RadGH/fd9b434c37698e8f2a75b557771e4d06 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
RadGH revised this gist
Jun 19, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,6 +27,8 @@ function rs_replace_create_post_block_template( $template ) { $_wp_current_template_content = $post->post_content; } // Note that block themes do not replace $template. If we did that, the block template would not be parsed. } return $template;  - 
        
RadGH revised this gist
Jun 19, 2024 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,10 @@ * @return string */ function rs_replace_create_post_block_template( $template ) { // Replace this conditional with your own logic to target a specific page or url: if ( get_query_var('my_action') === 'create_post' ) { global $_wp_current_template_id, $_wp_current_template_content; // Use a block template from the theme @@ -23,6 +26,7 @@ function rs_replace_create_post_block_template( $template ) { $_wp_current_template_id = wp_get_theme()->stylesheet . '//' . $block_template_slug; $_wp_current_template_content = $post->post_content; } } return $template;  - 
        
RadGH revised this gist
Jun 19, 2024 . No changes.There are no files selected for viewing
 - 
        
RadGH revised this gist
Jun 19, 2024 . No changes.There are no files selected for viewing
 - 
        
RadGH created this gist
Jun 19, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <?php /** * Before the block template is displayed, replace it with a different block template. * * IMPORTANT: You must create the block template through the editor: Templates > Add New * * @param string $template * * @return string */ function rs_replace_create_post_block_template( $template ) { if ( get_query_var('bb_crm_action') === 'create_post' ) { global $_wp_current_template_id, $_wp_current_template_content; // Use a block template from the theme $block_template_slug = 'wp-custom-template-crm-create-post'; // Get the block template post in the database $post = get_page_by_path( $block_template_slug, OBJECT, 'wp_template' ); if ( $post ) { $_wp_current_template_id = wp_get_theme()->stylesheet . '//' . $block_template_slug; $_wp_current_template_content = $post->post_content; } } return $template; } add_filter( 'template_include', 'rs_replace_create_post_block_template' );