Advertisement
campusboy

Для Александра

Jul 28th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. // Вариант 1
  4. $realty_type = get_field_object( 'sas_realty_type' );
  5.  
  6. if ( $realty_type ) { ?>
  7.     <div class="filter__item">
  8.         <select name="<?php echo $realty_type['name']; ?>">
  9.             <option selected="selected" disabled>Тип недвижимости</option>
  10.             <?php
  11.             foreach ( $realty_type['choices'] as $key => $value ):
  12.               ?>
  13.                 <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
  14.               <?php
  15.             endforeach;
  16.             ?>
  17.         </select>
  18.     </div>
  19.     <?php
  20. }
  21.  
  22. // Вариант 2
  23. $realty_type = get_field_object( 'sas_realty_type' );
  24.  
  25. if ( $realty_type ) {
  26.     $options = '<option selected="selected" disabled>Тип недвижимости</option>';
  27.    
  28.     foreach ( $realty_type['choices'] as $key => $value ) {
  29.         $options .= sprintf( '<option value="%s">%s</option>', $key, $value );
  30.     }
  31.    
  32.     $select = sprintf( '<select name="%s">%s</select>', $realty_type['name'], $options );
  33.    
  34.     printf( '<div class="filter__item">%s</div>', $select );
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement