Support » Developing with WordPress » Changing tags from a Gutenberg sidebar saves old ones on update

  • When I change post tags from my Gutenberg sidebar with

    const tags = 'core/editor' ).getEditedPostAttribute( 'tags' );
    const newTags = [...tags];
    newTags.push(1337);'core/editor').editPost({ 'tags': newTags });

    the UI will be updated (current tags correctly listed in standard post sidebar).

    But when I click the update button, the old tags are there again.

    When I execute 'core/editor' ).getCurrentPost(); via the developer tools console right before hitting the update button, the tags are correct. After clicking the update button, the tags are old again.

    Is this a bug or do I miss something?

    Note: this is more or less the same as but it is not working for me with version 5.9.3.

Viewing 1 replies (of 1 total)
  • Hi @papamufflon

    I just tested this code on a clean WP install running 5.9.3.

    To test it, I loaded up an empty post, added some sample data, and applied one tag in the UI. Then I opened the developer tools console, and ran each line of code, replacing your tag id with my own.

    The new tag was applied to my post, and when I clicked Update and then refreshed the page, it was still applied. So as far as I can see, your code is correct.

    Have you tried disabling all plugins and/or switching to a default theme, and seeing if the problem persists?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.