Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.81 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. elseif ( $meta_box['type'] == "attachment" ) {
  2.                        
  3.                         echo'<select name="'.$meta_box['name'].'_value">';
  4.                         $outer_post = $post->ID;
  5.                         $args = array(
  6.                                 'post_type' => 'attachment',
  7.                                 'numberposts' => -1,
  8.                                 'post_status' => null,
  9.                                 'post_parent' => $post->ID // any parent
  10.                         );
  11.                         $attachments = get_posts($args);
  12.                        
  13.                         if ($attachments) {
  14.                                 foreach ($attachments as $post) {
  15.                                         setup_postdata($post);
  16.                                         $option = $post->guid;
  17.                                         echo'<option value="';
  18.                                                 if ( get_post_meta($outer_post, $meta_box['name'].'_value', true) == $option ) {
  19.                                                         echo ' selected="selected"';
  20.                                                 } elseif ( $option == $meta_box['std'] ) {
  21.                                                         echo ' selected="selected"';
  22.                                                 }
  23.                                         echo $option .'">'.$post->post_title.'</option>';
  24.                                        
  25.                                 }
  26.                         }
  27.                        
  28.                         echo'</select>';
  29.                        
  30.                 }