In gutenberg I want to get a postmeta (it's a json string) that belongs to post #123. I want to check the editor's content against it. Let's say that postmeta's key is "blocks".
So I made this
(function () {
if (true === window.location.pathname.includes('post.php')) {
const unsubscribe = window.wp.data.subscribe(function () {
const arr = JSON.parse('{"first":"1","second":"2"}');
for (const key in arr) {
console.log(
wp.data
.select('core/editor')
.getEditedPostContent()
.includes(arr[key])
);
}
});
}
})();
Which works, I can get the content, but I want to replace arr
with the json that's in postmetas. Is there a way I can do this with wp.data? I can get current post's metas, but I want post #123's metas.