admin管理员组文章数量:1432164
I was still unable to find out that in Gutenberg. Specifically, i used:
wp.data.select("core/editor").getPostEdits();
to find out how many categories were checked. But it missed already checked categories... So, which function should I use to access in sum, how many categories are select at this moment? where is that data stored?
I was still unable to find out that in Gutenberg. Specifically, i used:
wp.data.select("core/editor").getPostEdits();
to find out how many categories were checked. But it missed already checked categories... So, which function should I use to access in sum, how many categories are select at this moment? where is that data stored?
Share Improve this question edited Apr 13, 2019 at 7:38 T.Todua asked Jan 3, 2019 at 17:29 T.ToduaT.Todua 5,8809 gold badges52 silver badges81 bronze badges1 Answer
Reset to default 6To get the categories from inside the editor of a post you can make use of the following selectors:
The categories the post has in the published version:
wp.data.select("core/editor").getCurrentPostAttribute("categories")
The current categories of the edit (for example if the user has selected a new category but hasn't saved the post it will appear with this selector but not with the former):
wp.data.select("core/editor").getEditedPostAttribute("categories")
This will give you an array with the id
of each category.
本文标签: block editorget selected categories or tags (using javascript) in GutenBerg
版权声明:本文标题:block editor - get selected categories or tags (using javascript) in GutenBerg? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745593381a2665329.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论