Elegant Themes Testimonial Shortcode - Add Link to Company Name and Uuthor Image


/ Published in: PHP
Save to your folder(s)

Enable link in Elegant Themes testimonials shortcode. Replace existing testimonial code in /et-theme-name/epanel/shortcodes.php with provided snippet. Shortcode will look like this: [testimonial link="yourlinkaddress.com" author="Author Name" company="Company Name" image="path-to-author-image"]blah blah blah[/testimonial]


Copy this code and paste it in your HTML
  1. /* === ORIG TESTIMONIALS
  2. add_shortcode('testimonial', 'et_testimonial');
  3. function et_testimonial($atts, $content = null) {
  4. extract(shortcode_atts(array(
  5. 'style' => '',
  6. 'id' => '',
  7. 'class' => '',
  8. 'author' => '',
  9. 'company' => '',
  10. 'image' => '',
  11. 'timthumb' => 'on'
  12. ), $atts, 'testimonial'));
  13.  
  14. $content = et_content_helper($content);
  15. $style = ( $style <> '' ) ? ' style="' . esc_attr( $style ) . '"' : '';
  16. $id = ($id <> '') ? " id='" . esc_attr( $id ) . "'" : '';
  17. $class = ($class <> '') ? esc_attr( ' ' . $class ) : '';
  18.  
  19. $orig_name = $author;
  20. $author = ( $author <> '' ) ? "<span class='t-author'>" . esc_html( $author ) . "</span>" : '';
  21. $company = ( $company <> '' ) ? "<span class='t-position'>" . esc_html( $company ) . "</span>" : '';
  22.  
  23. $image_markup = '';
  24. if ( $image <> '' ) {
  25. $image = ( $timthumb == 'on' ) ? et_new_thumb_resize( $image, 60, 60, '', $forstyle = true ) : $image;
  26. $image_markup = "
  27. <div class='t-img'>
  28. <img src='" . esc_attr( $image ) . "' alt='" . esc_attr( $orig_name ) . "' />
  29. <span class='t-overlay'></span>
  30. </div>
  31. ";
  32. }
  33.  
  34. $output = "
  35. <div{$id} class='et-testimonial-box{$class}'{$style}>
  36. <div class='et-testimonial-author-info clearfix'>
  37. {$image_markup}
  38. {$author}
  39. {$company}
  40. </div>
  41.  
  42. <div class='et-testimonial clearfix'>
  43. {$content}
  44. </div>
  45.  
  46. <div class='t-bottom-arrow'></div>
  47. </div>";
  48.  
  49. return $output;
  50. }
  51. */
  52.  
  53. /* === TESTIMONIALS ======================= */
  54. add_shortcode('testimonial', 'et_testimonial');
  55. function et_testimonial($atts, $content = null) {
  56. extract(shortcode_atts(array(
  57. 'style' => '',
  58. 'id' => '',
  59. 'class' => '',
  60. 'author' => '',
  61. 'company' => '',
  62. 'image' => '',
  63. 'link' => '',
  64. 'timthumb' => 'on'
  65. ), $atts));
  66.  
  67. $content = et_content_helper($content);
  68. $style = ( $style <> '' ) ? ' style="' . $style . '"' : '';
  69. $id = ($id <> '') ? " id='" . esc_attr( $id ) . "'" : '';
  70. $class = ($class <> '') ? esc_attr( ' ' . $class ) : '';
  71.  
  72. $orig_name = $author;
  73. $author = ( $author <> '' ) ? "<span class='t-author'>{$author}</span>" : '';
  74. $company = ( $company <> '' ) ? "<span class='t-position'><a href='{$link}' title='{$orig_name}'>{$company}</a></span>" : '';
  75.  
  76. $image_markup = '';
  77. if ( $image <> '' ) {
  78. $image = ( $timthumb == 'on' ) ? et_new_thumb_resize( $image, 60, 60, '', $forstyle = true ) : $image;
  79. $image_markup = "
  80. <div class='t-img'>
  81. <a href='{$link}' title='{$orig_name}'><img style='z-index: 99; position: relative;' src='{$image}' alt='{$orig_name}' /></a>
  82. <span class='t-overlay'></span>
  83. </div>
  84. ";
  85. }
  86. /* === END TESTIMONIAL ================*/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.