Guest User

Untitled

a guest
Jun 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. function mytheme_show_box2() {
  2.     global $meta_box2, $post;
  3.     echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
  4.     echo '<table class="form-table">';
  5.     foreach ($meta_box2['fields'] as $field) {
  6.         // get current post meta data
  7.         $meta = get_post_meta($post->ID, $field['id'], true);  
  8.         // let's get all the posts with custom post type 'papirutgave'
  9.         $myOptions = get_selectList_options('papirutgave');
  10.         // let's check if any old data is saved or not
  11.         $oldData = get_post_meta($post->ID,'tilknyttet_papirutgave',true);
  12.  
  13.         echo '<tr>',                
  14.                 '<td>';
  15.                 echo '<select name="', $field['id'], '" id="', $field['id'], '">';
  16.                 if($myOptions->have_posts()){
  17.                     if(!$oldData){
  18.                     echo '<option value="">Velg papirutgave</option>';                     
  19.                     }
  20.                     while ( $myOptions->have_posts() ) : $myOptions->the_post();?>
  21.                     <option <?php if($oldData && $oldData == get_the_title()){echo 'selected';}?>><?php the_title()?></option>
  22.                     <?php
  23.                     endwhile;                  
  24.                 }
  25.                 wp_reset_query();                          
  26.                 echo '</select>';          
  27.         }
  28.         echo     '<td>',
  29.             '</tr>';
  30.     echo '</table>';
  31. }
Add Comment
Please, Sign In to add comment