SHARE
TWEET

Iterate over all custom fields - Wordpress tutorial

jamesabruce Jul 16th, 2011 949 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top