Viewing 4 reply threads
  • Author
    Posts
    • #7883

      end goal: I want to copy a bunch of meta data from one post to the one I’m editing.

      I figured I’d start with the update multiple field. Here’s what I have so far:

      piklist('field', array(
        'type' => 'select'
          ,'field' => 'update_multiple'
          ,'label' => __('Update Multiple Fields', 'piklist-demo')
           ,'choices' => piklist(
                                   get_posts(array(
                                      'post_type' => 'event'
                                      ,'numberposts' => -1
                                      ,'orderby' => 'title'
                                      ,'order' => 'ASC'
                                  ))
                                  ,array('ID', 'post_title')
                              )
          ,'conditions' => array(
            array(
              'type' => 'update'
              ,'value' => 'true'
              ,'field' => 'update_multiple_1'
              ,'update' => __('Value 1', 'piklist-demo')
            )
            ,array(
              'type' => 'update'
              ,'value' => ''
              ,'field' => 'update_multiple_1'
              ,'update' => null
            )
            ,array(
              'type' => 'update'
              ,'value' => 'true'
              ,'field' => 'update_multiple_2'
              ,'update' => __('Value 2', 'piklist-demo')
            )
            ,array(
              'type' => 'update'
              ,'value' => ''
              ,'field' => 'update_multiple_2'
              ,'update' => null
            )
          )
        ));
      
        piklist('field', array(
          'type' => 'text'
          ,'label' => __('Update 1', 'pilist-demo')
          ,'field' => 'update_multiple_1'
        ));
      
        piklist('field', array(
          'type' => 'text'
          ,'label' => __('Update 2', 'pilist-demo')
          ,'field' => 'update_multiple_2'
        ));

      That’s as far as I’ve gotten. I can select a post from the select option choices but how do I get the selected post data so I can copy it to the other meta fields?

    • #7889
      Steve
      Keymaster

      Not sure exactly, what you are trying to do, but to copy post meta from one post to another you would use get_post_meta() and update_post_meta().

    • #7890

      Thanks steve, I should have been clearer. I am trying to get access to what was selected in the view as the option.

      For this part:

      'type' => 'select'
          ,'field' => 'update_multiple'
          ,'label' => __('Update Multiple Fields', 'piklist-demo')
           ,'choices' => piklist(
                                   get_posts(array(
                                      'post_type' => 'event'
                                      ,'numberposts' => -1
                                      ,'orderby' => 'title'
                                      ,'order' => 'ASC'
                                  ))
                                  ,array('ID', 'post_title')
                              )

      How do I get the post that was selected? Do I need to use jquery or does piklist return it somehow?

    • #7895

      I think this post is similar.

      update multiple from resulting post selection

      I’m trying to get the selected post so I can update the other fields. It looks like you solved it but it was done via email and not posted in the forum.

      Let me know how it’s possible.

      Thanks, Steve!

    • #7906

      Anyone have any advice here? I’d love to get that selected option back but am not sure just how to do so.

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