Advertisement
iEmanuele

Untitled

Jun 12th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. $args = array(
  2.     'post_type' => 'agent',
  3.     'posts_per_page' => -1
  4. );
  5.  
  6. $agencies = get_posts( $args );
  7.  
  8. if( !empty($agencies) ){ ?>
  9.     <select>
  10.         <option value="">Please select</option>
  11. <?php foreach( $agencies as $agency ){ ?>
  12.         <option <?php selected( get_option('id_agency'), $agency->ID, true ); ?> value="<?php echo $agency->ID; ?>">
  13.             <?php echo $agency->post_title; ?>
  14.         </option>
  15. <?php } ?>
  16.     </select>
  17. <?php }else{ echo 'No agencies found'; } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement