Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When use editEntityRecord for content it doesn't render automatically. #249

Open
mijan-xs opened this issue Apr 2, 2023 · 0 comments
Open

Comments

@mijan-xs
Copy link

mijan-xs commented Apr 2, 2023

 const handlePageImport = async (page) => {
    const { getCurrentPostId, getCurrentPostType, getEditedPostContent } = select('core/editor');
    const { getEntityRecord } = select('core');
    const { editEntityRecord, saveEditedEntityRecord } = dispatch('core');
    const postId = getCurrentPostId();
    const postType = getCurrentPostType();
    const content = getEditedPostContent();
    const post = getEntityRecord('postType', postType, postId);
    await editEntityRecord('postType', postType, postId, {
        content: content + page.content,
    });
    await saveEditedEntityRecord('postType', postType, postId);
}

I used this code to import my demo from a custom post type. It imports my demo content to the page but doesn't render until I reload the page manually. After manually reloading I can see my demo content. but if I updated only the title then it's rendered automatically but only when I update the post manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant