Advertisement
jamesabruce

Iterate over all custom fields - Wordpress tutorial

Jul 16th, 2011
1,171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. $custom_fields = get_post_custom($post->ID);  
  3. $my_custom_field = $custom_fields['my_custom_field'];  
  4. foreach ( $my_custom_field as $key => $value ) {  
  5.     if ($key == ‘Level’){    
  6.         switch ($value){     
  7.             case ‘Easy’:     
  8.                 echo<img src=‘easy.gif’>;     
  9.                 break;   
  10.             case ‘Difficult’:    
  11.                 echo<img src=‘difficult.gif’>;    
  12.                 break;
  13.         }    
  14.     }
  15.     else{    
  16.         echo $key .: " . $value . "<br />";  
  17.     }
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement