Tagged: 

Viewing 5 reply threads
  • Author
    Posts
    • #3745
      vgrch
      Member

      Hello,

      I’m building a daily report divided into 3 parts: morning, afternoon and evening. Each of parts has the same set of fields including related custom posts (field names have respective suffix so they all are different).

      Is it possible to include the same set of related posts for each part?

      Thanks.

    • #3754
      Steve
      Keymaster

      @vgrch– I’m not 100% clear on your question, however, this may help.

      You don’t have to include the field code in each part file. You can have it sit in your main plugin file wrapped in a function, and then call that function in the part file.

      For example:

      In your main plugin file, or theme’s functions.php, add this:

      function my_text_field()
      {
          $field = array(
            'type' => 'text'
            ,'field' => 'my_text_field'
            ,'label' => __('My Text Field')
          );
      
          return $field;
       }
      

      And then in your parts files just call this:
      my_text_field();

      Does that help?

    • #3768
      vgrch
      Member

      I see the idea but it didn’t work.

      I need to attach post-to-post field, so in functions.php I added:

      function djs_field()
      {
          $field = array(
              'type' => 'post-relate'
              ,'scope' => 'dj'
              ,'template' => 'field'
          );
          return $field;
      }

      And in piklist/parts/meta-boxes/fields.php added:

      djs_field();

      But it didn’t change a thing, anything I’m doing?

      Thanks.

    • #3769
      Steve
      Keymaster

      I guess I didn’t understand your question. Can you provide more details?

    • #3775
      vgrch
      Member

      No problem. So we a talking about daily reports for a restaurant.

      I have custom post type called Daily Reports. Each one has meta-boxes for morning, afternoon and evening reports, each of them with the same set of fields, like weather (choose from dropdown), manager (choose from users), revenue etc.

      I also have a custom post type called DJ. Each meta-box of Daily Reports has to have it’s own dropdown with the list of DJs to choose, so we have 3 DJs attached to 1 report.

      My problem is to show DJ dropdowm 3 times in 1 report.

      I hope I explained more than confused. )
      Thanks.

    • #3790
      Steve
      Keymaster

      @vgrch– If you have it showing once, you can easily copy the code to each meta box… however, you will have to change the field name on each. You can’t have the same field name more than once per form.

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