Is there any way to create a block template for a single page or page template?
-
I have been trying to create a block template but only want it to show up on the “Home” page for the website. I have not found any way to make this work as I cannot access anything but the post ID in the “init” hook and this theme runs on multiple websites with different post IDs for the page called “Home”
I am looking for ways to somehow make this work so when a user goes to edit the “Home” page under Pages, they are shown the block template that cannot be removed or re-arranged.
function create_homepage_block_template() { if (!is_admin() || !is_page('Home')) { return false; } $post_type_object = get_post_type_object('page'); $post_type_object->template = array( array('homepage/featured-content', array( 'align' => 'full', )), array('homepage/featured-modules', array( 'align' => 'full', )), array('homepage/posts-box', array( 'align' => 'full', )), ); $post_type_object->template_lock = 'all'; } add_action('init', 'create_homepage_block_template');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.