Advertisement
eventsmanager

show latest comment using custom placeholder

Jul 3rd, 2013
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. add_filter('em_event_output_placeholder','my_em_placeholder_mod_comment',1,3);
  2. function my_em_placeholder_mod_comment($replace, $EM_Event, $result){
  3. if ( $result == '#_EVENTCOMMENT' ) {
  4. $replace = 'n/a';
  5. $args = array( 'post_id' => $EM_Event->post_id, 'count' => false, 'comment_content' => true, 'orderby' => 'comment_date_gmt', 'number' => 1 );
  6. $comments = get_comments($args);
  7. foreach($comments as $comment) :
  8. $replace = $comment->comment_content;
  9. endforeach;
  10. }
  11. return $replace;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement