Tagged: ,

Viewing 3 reply threads
  • Author
    Posts
    • #1229
      Marcus
      Member

      Is 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

    • #1230
      Kevin
      Keymaster

      Hi 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

    • #1232
      Marcus
      Member

      Kevin, 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

    • #1236
      Kevin
      Keymaster

      That’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

Viewing 3 reply threads
  • You must be logged in to reply to this topic.