Title: Adding a Gutenberg block programmatically
Last modified: June 17, 2020

---

# Adding a Gutenberg block programmatically

 *  Resolved [Tom Geller](https://wordpress.org/support/users/tgeller/)
 * (@tgeller)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/adding-a-gutenberg-block-programmatically/)
 * Beginning WordPress developer here. I’m working with a legacy database with lots
   of information in custom fields (originally created with ACF). Among them are
   videos I’d like to put in a Gutenberg “Embed” block, e.g. from YouTube.
 * I’ve created a custom theme (child of twentytwenty). I’ve made other custom fields
   appear (as plain text) by adding them to template-parts/content.php, below “the_content”.
 * My plan has been to add code like, “If there’s data in the wpcf-embedded-media
   field, add an Embed block to the page and stick the data in there.” But I can’t
   figure out the “add an Embed block to the page” part.
 * Of course I’d welcome suggestions for other ways to do this. Thanks in advance
   for your help!
    -  This topic was modified 5 years, 11 months ago by [Tom Geller](https://wordpress.org/support/users/tgeller/).
    -  This topic was modified 5 years, 11 months ago by [Tom Geller](https://wordpress.org/support/users/tgeller/).
    -  This topic was modified 5 years, 11 months ago by [Tom Geller](https://wordpress.org/support/users/tgeller/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/adding-a-gutenberg-block-programmatically/#post-12999369)
 * You’re thinking of it a little skewed. The “block” part is for the user interface
   in the editor. That block markup gets rendered before the theme gets `the_content`.
   To add to what the theme is outputting, you simply need to filter the appropriate
   thing. For legacy content, that means getting the post meta fields and adding
   them to the_content.
    Or you can manipulate your database, so that it’s not in
   post meta anymore, but directly in the content. Embeds work with no extra markup
   needed – simply the URL on a line by itself.
 *  Thread Starter [Tom Geller](https://wordpress.org/support/users/tgeller/)
 * (@tgeller)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/adding-a-gutenberg-block-programmatically/#post-12999375)
 * Thank you so much! You’ve cleared up a few things for me. I was just sitting 
   down to work on this; now I have much better focus.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding a Gutenberg block programmatically’ is closed to new replies.

## Tags

 * [embed](https://wordpress.org/support/topic-tag/embed/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [vimeo](https://wordpress.org/support/topic-tag/vimeo/)
 * [Youtube](https://wordpress.org/support/topic-tag/youtube/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Tom Geller](https://wordpress.org/support/users/tgeller/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/adding-a-gutenberg-block-programmatically/#post-12999375)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
