Advertisement
srikat

Untitled

Mar 10th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. function be_display_posts_read_more( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class ) {
  2.  
  3. // First check if an excerpt is included by looking at the shortcode $atts
  4. if ( $atts['include_excerpt'] )
  5. // Now let's rebuild the excerpt to include read more
  6. $excerpt = '<span class="excerpt">' . get_the_excerpt() . '<br /><br /><a class="more-link" href="' . get_permalink() . '">Read the full testimonial &raquo;</a></span>';
  7. else $excerpt = '';
  8.  
  9. // Fetch the custom field values and store them in variables
  10. $name = esc_html( get_post_meta( get_the_ID(), 'name', true ) );
  11. $title = esc_html( get_post_meta( get_the_ID(), 'title', true ) );
  12. $organization = esc_html( get_post_meta( get_the_ID(), 'organization', true ) );
  13.  
  14. if ( $name || $title || $organization ) {
  15. $testimonial_meta = '<div class="testimonial-meta">';
  16. }
  17.  
  18. if ( $name ) {
  19. $testimonial_meta .= '<p>Name: ' . $name . '</p>';
  20. }
  21.  
  22. if ( $title ) {
  23. $testimonial_meta .= '<p>Title: ' . $title . '</p>';
  24. }
  25.  
  26. if ( $organization ) {
  27. $testimonial_meta .= '<p>Organization: ' . $organization . '</p>';
  28. }
  29.  
  30. if ( $name || $title || $organization ) {
  31. $testimonial_meta .= '</div>';
  32. }
  33.  
  34. // Now let's rebuild the output. Only the excerpt changed so we're using the original $image, $title, and $date
  35. $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $excerpt . $content . $testimonial_meta . '</' . $inner_wrapper . '>';
  36.  
  37. // Finally we'll return the modified output
  38. return $output;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement