dragunoff

[WP] Simple Term Metadata

Apr 4th, 2011
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. /*
  2.  * Parse data stored as term description
  3.  *
  4.  * @param string $meta Term description formatted with new line for earch 'field'
  5.  * @param string $field Field to return
  6.  *
  7.  * @return string $output String to use in templates
  8.  */
  9. function custom_term_meta( $meta, $field = 'meta' ) {
  10.  
  11.     // explode array on new line
  12.     $meta = explode("\n", $meta);
  13.    
  14.     // decide what to output
  15.     switch ($field) {
  16.        
  17.         case 'description':
  18.             $output = $meta[0];
  19.             break;
  20.            
  21.         case 'thumb':
  22.             $output = $meta[1];
  23.             break;
  24.            
  25.         case 'link':
  26.             $output = $meta[2];
  27.             break;
  28.        
  29.         case 'meta':
  30.             $output = $meta[0];
  31.             $output .= $meta[2];
  32.             break;
  33.        
  34.     }
  35.  
  36.     // formatting for archive views
  37.     if( is_category() || is_tag() || is_tax() ) {
  38.    
  39.         $output = make_clickable( $output );
  40.        
  41.     }
  42.    
  43.     return $output;
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment