Last active
July 1, 2020 01:59
-
-
Save haveboard/e85a3a33be22cb2fcb3e1d90c25ba46f to your computer and use it in GitHub Desktop.
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
<?php | |
if ( ! class_exists( 'Custom_Post_Template' ) ) { | |
class Custom_Post_Template { | |
const POST_TYPE = 'post'; // what ppst type would you like to make this template for | |
public function __construct() { | |
add_action( 'init', array( &$this, 'init' ) ); | |
add_filter( 'gettext', array( &$this, 'add_custom_post_placeholder' ) ); | |
} // END __construct | |
public function init() { | |
$this->custom_post_template(); | |
} // END init | |
public function add_custom_post_placeholder( $input ) { | |
global $post_type; | |
if ( is_admin() && 'Add title' == $input && self::POST_TYPE == $post_type ) { | |
return 'Enter A Post Title Here'; | |
} | |
return $input; | |
} // END add_custom_post_placeholder | |
public function custom_post_template() { | |
$custom_post_template = array( | |
array( | |
'core/columns', // note outer is plural columnS | |
array('className'=>'container-classname'), // give the template column a class | |
array( | |
array( | |
'core/column', // note singular inner column (no S) | |
array('className'=>'post-custom-col'), // give the template inner column a class | |
array( | |
array( | |
'core/paragraph', // set a paragraph block inside your custom column template | |
array( | |
'className'=>'custom-paragraph-class', // give the template inner column a class | |
'placeholder' => 'Add content or additional blocks' // set placeholder text | |
) | |
), | |
) | |
), | |
array( | |
'core/column', // note singular inner column (no S) | |
array('className'=>'post-custom-col-b'), // give the template inner column a class | |
array( | |
array( | |
'core/list', // set a list block inside your custom column template | |
array( 'placeholder' => 'write list' ) // set placeholder text | |
), | |
) | |
), | |
) | |
), | |
array( | |
'core/paragraph',// set a paragraph block after your custom template columns | |
array( | |
'className'=>'custom-paragraph-class',// give the first default paragrapha class | |
'placeholder' => 'Add content or additional blocks' // set placeholder text | |
) | |
), | |
); | |
$post_type_object = get_post_type_object( self::POST_TYPE ); | |
$post_type_object->template = $custom_post_template; | |
} | |
} // END class Custom_Post_Template | |
} // END if class_exists | |
$custom_post_template = new Custom_Post_Template(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment