- This topic has 3 replies, 2 voices, and was last updated 8 years, 3 months ago by
Kevin.
-
AuthorPosts
-
-
November 11, 2013 at 1:31 am #1229
MarcusMemberIs it possible for a meta box, on a CPT to show data from a different CPT, yet not be editable.
The reason I ask is I have two CPT’s. One called Parents, and one called children.
When viewing a parent, I want to be able to show all the children that are attached to that parent (but do not want the data editable)
And on the childrens, I want the info on the attached parent to be visible but not editable.
Is this possible with Piklist, or should I just build my own metaboxes for this?Thanks guys.
Marcus
-
November 11, 2013 at 1:35 am #1230
KevinKeymasterHi Marcus-
Well you can put anything into a meta box and include said box on an edit screen. For something like this I would use the post_relationships piece in Piklist and then use the query_posts function to show what is associated in a meta box. See the field-relate.php meta-box included in the demos to see what I am referring to.
Thanks,
Kevin
-
November 11, 2013 at 2:05 am #1232
MarcusMemberKevin, so if I understand you and the demo correctly…
I create a parent in my parents CPT.
For the children’s CPT, I select the parent through a post-relate field. (how do I turn this into a select box)
Now to show the different children in the parents screen, would be as simple as duplicating the code you used in the field-relate.php file below the meta box and changing the args too:$args = array( 'post_type' => 'children' ,'post_belongs' => $post_id ,'posts_per_page' => -1 ,'post_status' => 'publish' );Jess, No? Am I close?
Marcus
-
November 11, 2013 at 2:15 am #1236
KevinKeymasterThat’s it exactly. As for the select field, you just need to populate it with the ids for the children (assuming this is on the parent edit screen) and set the scope to ‘relate’ and the field to ‘{ANYTHING}_post_id’ and thats it. The post-relate fields sets anything to the post type of the children, in the case of the demo ‘piklist_demo’.
Thanks,
Kevin
-
-
AuthorPosts
- You must be logged in to reply to this topic.