Hey visitors! If you're a beginner in WordPress and WP-CLI development, then you should check out my dear friend Bhargav's Youtube channel! @BuntyWP

How to add/edit a post title programmatically in WordPress Gutenberg?

by Siddharth Thevaril

The post title is part of the Post Editor data, stored in the core/editor data store.

To add/edit the post title, we will make use of the editPost action in the following way:

wp.data.dispatch( 'core/editor' ).editPost( { title: 'This is the post title' } );Code language: JavaScript (javascript)

That’s it. You can try this command in the browser’s developer console as seen in the video below:

Subscribe to the Newsletter
Subscribe to get my latest content by email.

Leave a Reply