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”
- Keyboard shortcut for updating a page or post?
- Apply the_title() filter in post & page title, but not in menu title
- Confirmation box when submitting post for review
- Remove post title input from edit page
- Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg
- Get the current post ID as a variable in Javascript
- How to create WP Editor using javascript
- Disallow Same Post Title
- Get title of post without using the_title();
- Verify if tag is used on posts
- Add javascript when post is published
- Getting an alphabetic post list with two letters onclick on letter
- How to load post content on index page using ajax when post title in sidebar is clicked
- 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
- “Uncaught SyntaxError: Unexpected token
- Displaying Page Title on index.php
- 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
- Add Category name to Post Title (h1)
- How to add a custom field after wp post
- 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
- How to create a load more post entries like Twitter?
- Disable Jquery UI post tabs
- Injecting JavaScript into a Post with WP3.x
- I want to show category in the post title , how can I do
- How can I get a post field value using javascript?
- How to prevent WordPress from updating the modified time?
- 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
- Blog Posts not showing title
- Lose “Blog Archive” from page title
- How to Orderby Comments by post 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
- WP_Query with ajax handler returns the same posts
- Block Editor: Reset Reusable Blocks to last saved record
- Ajax post filters not working
- 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
- WordPress is replacing double minus signs in Post Title, how to disable it?
- How do I change the core post search algorithm? Where is it found/constructed?
- Do all wordpress themes a similar class name for content?
- Is there a way to specify an extra class for a post or page with no title?
- Only show a Post once in 10 visits
- Security to delete post by Admin
- Add title for previous and next posts to Yoko Theme
- Images inside post title
- Loop doesn’t show title of second post and posts thereafter
- How To capitalize The First Letter Of Every Word In The Post Title
- add bootstrap post slider with tabs
- How to show show the Second page title in the page
- In post.php how can I remove onbeforeunload?
- How to get links to the last N posts in a specific category?
- Create a list of posts with topic headdings
- 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
- Edit the post title from the frontend
- Navigate through the posts using keyboard arrows
- Why in my query is display two title?
- Image behind the post’s 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
- Get featured image on hover of post title [closed]
- Adding JS functionality to the Publish button in wp-admin/post.php
- Microformats in a single post – layout conflict
- How do I display the post_title with get_permalink?
- Get content from WordPress posts in Boostrap modal window – Javascript side?
- Post titles and thumbnails as links to custom post types?
- If post exists, make it a comment in existing post with same name?
- Insert specific information to a posts of a predefined category
- displaying the categories post