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

      Whoohoo, playing with the new beta…

      I want to get all the data for attachments that have a piklist meta box in them. (and I only want to get the attachmets that have been set to a specific select field)

      Here’s the piklist meta box I created:`
      <?php
      /*
      Title: Slideshow Image <span class=”piklist-title-right”>Choose Below</span>
      Post Type: attachment
      Order: 110
      Priority: default
      Context: normal
      Locked: true
      Collapse: false
      */

      piklist('field', array(
      'type' => 'select'
      ,'scope' => 'post_meta'
      ,'field' => 'slideshow-image'
      ,'label' => 'Show in Slideshow?'
      ,'description' => 'Please select the slideshow you would like to show this image in.'
      ,'value' => 'no_slideshow'
      ,'attributes' => array(
      'class' => 'text'
      )
      ,'choices' => array(
      'no_slideshow' => 'No'
      ,'slideshow_main' => 'Slide #1 – Main Slideshow'
      ,'slideshow_second' => 'Slide #2'
      ,'slideshow_third' => 'Slide #3'
      )
      ));

      ?>
      `

      All I need to know, is how to access the data. LOL

      Pre-thanks

      Marcus

    • #921
      Kevin
      Keymaster

      I think your over thinking it… 🙂

      $meta = get_post_meta($post_id, ‘slideshow-image’, true); // false it not unique
      $meta = get_metadata(‘post’, $post_id, ‘slideshow-image’, true); // false it not unique
      $all_meta = piklist(‘post_custom’, $post_id);

      Thanks,

      Kevin

    • #922
      Marcus
      Member

      Ok, that helps and is getting me on the right track. Thanks for that.

      It’s helped another question come to the top.

      I added in conditions on that meta box, so that one of the fields is a select, and the next one is conditional based on several responses.

      Is this currently possible?

      By using something like:

      
         ,'conditions' => array(
            array(
            'field' => 'theme-select'
            ,'value' => 'sidebar_main'
            ),
            array(
            'field' => 'theme-select'
            ,'value' => 'sidebar_second'
            ),
            array(
            'field' => 'theme-select'
            ,'value' => 'sidebar_third'
            )
          )
         ));
      

      Or is it only useful for one condition?

      Thanks Kevin.

      Marcus

    • #924
      Marcus
      Member

      Ok, Kevin, I hope you can help.

      I’m now trying to add a slideshow options meta box, to pages.

      Pretty simple. But right now, I’m not sure if its me, or its a bug.

      I’ve followed your old example pretty closely:
      (here’s my slideshow images meta box)

      
      <?php
      /*
      Title: Select Slideshow Images <span class="piklist-title-right">Choose Below</span>
      Post Type: page
      Order: 110
      Priority: default
      Context: normal
      Collapse: false
      */
      
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'post_status'
          ,'scope' => 'slideshow_image_post'
          ,'value' => $post->post_status
        ));
       
        piklist('field', array(
          'type' => 'textarea'
          ,'field' => 'post_excerpt'
          ,'scope' => 'slideshow_image_post'
          ,'label' => 'Attachment Notes'
          ,'attributes' => array(
            'class' => 'large-text'
          )
        ));
      
        piklist('field', array(
          'type' => 'file'
          ,'scope' => 'post'
          ,'field' => 'slideshow_image_post'
          ,'label' => 'Select Images for Slideshow'
          ,'description' => 'Please select the images you would like'
          ,'add_more' => true
         ));
      
        $args = array( 
          'post_type' => 'attachment' 
          ,'numberposts' => -1
          ,'post_parent' => $post->ID 
          ,'post_status' => 'all'
        ); 
      
        
        $attachments = get_posts( $args );
        if ($attachments)
        {
          global $wp_post_statuses;
          remove_all_filters('get_the_excerpt'); // Since we're using the_excerpt for notes, we need to keep it clean.
      
          foreach ( $attachments as $post )
          { 
            setup_postdata($post); ?>
      
            <div id="pik_post_attachment_<?php echo $post->ID; ?>" class="piklist-field-container">
              <div class="piklist-label-container">
                <!-- Edited by Marcus - Changed attachments > post -->
                <?php echo wp_get_attachment_link( $post->ID, 'thumbnail', false, true ); ?>     
              </div>
              <div class="piklist-field">
                <?php printf( __('%1$sOrder Status:%2$s %3$s','piklist'),'<strong>','</strong>',$wp_post_statuses[$post->post_status]->label); ?>
                <?php the_excerpt(); ?>
              </div>
            </div>
      <?php
          }
      
        }
      
      ?>
      

      Whenever I select a file, it doesn’t upload.

      Am I missing something? There is only one file here, under meta-boxes folder in parts.

      Marcus

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