Advertisement
josh_max

WP Custom Comments

Jul 6th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2.     /** This code outputs the Custom Comment fields **/
  3.  
  4.     // set an empty array
  5.     $cArr = array();
  6.     // array-ify the fields
  7.     $cfields = array_filter(explode(",", get_option('CComment_fields')));
  8.  
  9.     // add value of each field to empty array
  10.     foreach ($cfields as $cfield){
  11.         $cVal = get_comment_meta(get_comment_ID(), "CuCo_".$cfield);
  12.         $cArr[] = $cVal[0];
  13.     }
  14.     // set variables for each item in array
  15.     // (obviously, set these to what your's are...)
  16.     list( $city, $state, $start, $end ) = $cArr;
  17.    
  18.     // finally, spit it all out
  19.     // (display YOUR variables however YOU need...)
  20.     echo "From: $city, $state <br/>";
  21.     echo "Stayed: $start to $end <br/>";
  22.  
  23.     // reset array for next comment
  24.     // (not sure if this is needed, set it just to be safe)
  25.     $cArr = null;
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement