It’s a common practice to use the post_parent
property in the WP_Post
class to create 1-to-n relationships between different custom post types.
In an plugin I’m developing, I added a SelectControl
to the PluginDocumentSettingPanel
to be able to set the id of a related custom post type in another custom post type. According to the docs, I should use getEditedPostAttribute
to retrieve the current “parent” (the id of the related custom post type) of the custom post type being edited:
But, for some reason, I’m getting an undefined
value even though the post_parent
property is set. A custom meta box in the classic editor shows it correctly.
If I set the hierarchical
property in the custom post type to true
, the selector works and I get the correct value. Is this by design? Or are we forced to use a custom meta field to store this data, now?
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com