Skip to content

Commit

Permalink
Add more context to Templates sample code (#4557)
Browse files Browse the repository at this point in the history
* Add function and add_action call to sample code

* Better function name
  • Loading branch information
laras126 authored and youknowriad committed Jan 18, 2018
1 parent b8566d7 commit e826be5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ Sometimes the intention might be to lock the template on the UI so that the bloc
It is also possible to assign a template to an existing post type like "posts" and "pages":

```php
$post_type_object = get_post_type_object( 'post' );
$post_type_object->template = array(
array( 'core/paragraph', array(
'placeholder' => 'Add Description...',
) ),
);
$post_type_object->template_lock = 'all';
function my_add_template_to_posts() {
$post_type_object = get_post_type_object( 'post' );
$post_type_object->template = array(
array( 'core/paragraph', array(
'placeholder' => 'Add Description...',
) ),
);
$post_type_object->template_lock = 'all';
}
add_action( 'init', 'my_add_template_to_posts' );
```

0 comments on commit e826be5

Please sign in to comment.