Post content in the Gutenberg block
-
Good day.
For my Gutenberg block I need to show an another post’s content (it is created by Gutenberg too). I can read and show the content, but it is shown as a html text, not as result. For example:
<strong>My post content</strong>
instead of My post content
This is my code:
export default function Edit({ attributes, isSelected }) { const blockProps = useBlockProps(); const data = useSelect((select) => { return select('core').getEntityRecords('postType', 'slider', { per_page: 1 }); }); // Has the request resolved? const isLoading = useSelect((select) => { return select('core/data').isResolving('core', 'getEntityRecords', [ 'postType', 'slider' ]); }); // Show the loading state if we're still waiting. if (isLoading) { return <h3>Loading...</h3>; } return ( <div {...blockProps}> { data && data.map(({ content: { rendered: postContent } }) => { return <div>{postContent}</div>; }) } </div> ); }
Is there way to show already formatted content, not its html presentation?
Thank you in advance,
Serge
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Post content in the Gutenberg block’ is closed to new replies.