The block editor is restoring back the title that was last saved (or typed manually into the textarea), so with the block editor, you can change the title dynamically using this code:
wp.data.dispatch( 'core/editor' ).editPost( { title: 'Title here' } )
PS: You should make sure your JS file has the wp-editor
, wp-edit-post
or wp-data
as part of the dependencies.
UPDATE
Here are the resources which helped me identify the above solution/code:
-
https://developer.wordpress.org/block-editor/packages/packages-data/#dispatch
-
https://riad.blog/2018/06/07/efficient-client-data-management-for-wordpress-plugins
-
https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/components/post-title/index.js (the React component which setups the title textarea / UI)
Related Posts:
- Ajax Load More Posts in Category Page
- Add confirmation popup on “Move to Trash”
- Ajaxify This Code
- Call current post URL in ajax
- Using the loop to set locations for all posts on a single google map
- Ajax post doesnt call succes after got the response
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- How to change the case of all post titles to “Title Case”
- Confirmation box when submitting post for review
- Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg
- How to create WP Editor using javascript
- Get title of post without using the_title();
- Getting an alphabetic post list with two letters onclick on letter
- How to show posts rank based on custom field value
- Get post from custom REST endpoint in Gutenberg
- POST from jQuery to PHP
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- How to intercept Post Title on Post-Save
- Testing for post title in ‘if/else’ statement returns no content
- get_post_field – Title without paragraph
- Create a separate JS application for an individual post?
- The correct way to call posts with ajax
- How do I use Ajax to show the new posts realtime, on the frontpage
- Convert a complex webpage into WP theme
- Sorting posts alphabetical that have single digits
- How Can i Get 5 Recent Post Title With Corresponding Link?
- Add scripts on custom post add/edit pages Not Working
- Disable Jquery UI post tabs
- I want to show category in the post title , how can I do
- How to display following posts titles in separate div’s on a separate webpage
- jQuery inluclude still seems ncessary for script to work within post
- Lose “Blog Archive” from page title
- Custom post preview without saving
- Ajax load more button in Recent posts widget
- WordPress not opening posts with only numbers if permalink is post_name
- Ajax Dynamic Archives not showing correct results
- Block Editor: Reset Reusable Blocks to last saved record
- Integrate OpenStreetMap on WordPress
- Genesis + Ajax + Jquery | Failling to call action
- Post repeating with infinite scroll
- sql select for post_title and a term name
- How do I locate the exact location where this error is occurring 404 page not found
- How do I change the core post search algorithm? Where is it found/constructed?
- Is there a way to specify an extra class for a post or page with no title?
- Add title for previous and next posts to Yoko Theme
- Images inside post title
- How To capitalize The First Letter Of Every Word In The Post Title
- How to show show the Second page title in the page
- How to get links to the last N posts in a specific category?
- Use Click Image to Play Youtube Video in a WordPress Loop
- Blog post not showing title
- How can I remove the first two words and shorten get_the_title()
- How do I include the category next to the title of a post?
- How to style archive post titles… but only those posts who have comments?
- Replace image name on upload to the new post name on front-end form
- Why in my query is display two title?
- Change Post Title For Specific Category
- How to remove “» (title of post or page)”?
- Auto update post title and slug when post status is changed
- datepicker value in mysql
- Adding JS functionality to the Publish button in wp-admin/post.php
- Microformats in a single post – layout conflict
- Post titles and thumbnails as links to custom post types?
- displaying the categories post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Insert JavaScript in a blog post or a new page?
- Changing The Default Header POST Title and Description text by category in wordpress
- Change modified date to current date when title updated automatically
- Why is it recommended to insert JS through the theme, plugin, etc rather than in the post directly?
- Post title not displaying as recorded in the wp_posts table
- Create/Set Category as Title of Post
- long-title posts do not want published
- Many buttons not functioning in WordPress dashboard (as admin)
- Please I want to prefix my WP posts title according to each category
- Post title spoiler how?
- 2 Domains, Same Content, Different Titles?
- testing result of $.post with json_encode
- How do I use slideToggle inside a wordpress post?
- Printable Page with all Posts from Tag
- Hide title in Merlin Theme on posts and pages only
- How can I choose and change a post title at random from an array when it is published?
- Post title to show all characters after having it limited for preview
- problem with creating a wordpress post slider
- Get post title by Alphabet
- Get post id on click of thumbnail
- How to get all post titles starting with numbers and symbols?
- Custom Post Title as search term
- Is there a way to separate wordpress titles from their posts?
- display only the title of the post into a certain category
- How do I show the post title if an advanced custom field hasn’t been used?
- Deleting first four characters from all Post Titles
- Single post pagination
- How remove “recent comments” title without modifying code? [closed]
- clicking on page title
- Title displaying multiple times
- How to hide a script ( an ad) from a specific post? [closed]
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- WP Rest API feature image breaking react component
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- How to link Post Title to uploaded file?