Title: Example of function implementation
Last modified: August 21, 2016

---

# Example of function implementation

 *  [blackbookdesign](https://wordpress.org/support/users/blackbookdesign/)
 * (@blackbookdesign)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/)
 * hi,
    I would love to get an example of how to implement the “ct_pre_render_testimonial”
   function in my theme to output a different structure as per yours.
 * Shortly I would need to know where and how to do this.
    I reckon it should be
   in my function.php file but I don’t know what i need to apply the filter.
 * Thanks for pointing me out in the right direction.
 * Best regards
 * [https://wordpress.org/plugins/clean-testimonials/](https://wordpress.org/plugins/clean-testimonials/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [lukerollans](https://wordpress.org/support/users/hellolukerollansme/)
 * (@hellolukerollansme)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080317)
 * Hi there,
 * The ct_pre_render_testimonial filter is designed to allow you to completely override
   how a testimonial is displayed. It passes through two variables. The first is
   the WP_Testimonial object and the second is the context in which the testimonial
   is being displayed. EG, a shortcode.
 * The below example will output just the testimonial title, instead of the default
   display. This isn’t very useful, but should illustrate how the filter is used.
 * The code should go somewhere in your themes functions.php file.
 *     ```
       function render_my_testimonial ( $testimonial, $context ) {
           return '<p>' . $testimonial->post_title . '</p>';
       }
       add_filter( 'ct_before_render_testimonial', 'render_my_testimonial', 10, 2);
       ```
   
 * The code above has not been tested.
 * Filters like this are for advanced developer use only. We can’t provide support
   or examples beyond this, given it is only a free plugin 🙂
 * Hope that helps!
 * If you have found the plugin useful, please consider taking a moment to rate 
   it.
 *  Thread Starter [blackbookdesign](https://wordpress.org/support/users/blackbookdesign/)
 * (@blackbookdesign)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080324)
 * Thanks heaps this is exactly what I wanted. Thanks for the good support.
    Now
   time to rate your plugin. 😉 cheers
 *  Thread Starter [blackbookdesign](https://wordpress.org/support/users/blackbookdesign/)
 * (@blackbookdesign)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080325)
 *  Thread Starter [blackbookdesign](https://wordpress.org/support/users/blackbookdesign/)
 * (@blackbookdesign)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080371)
 * hummm after modifying your snippet I was only able to output a string on echo
   and not return. But Testimonials are still getting printed in addition to my 
   code. Did you recently test this feature in your dev (filter hook)?
    Return doesn’t
   show anything… There’s no further documentation in the forum or git so last resort
   is here. I’ll buy you a beer 😉
 *  Plugin Author [lukerollans](https://wordpress.org/support/users/hellolukerollansme/)
 * (@hellolukerollansme)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080420)
 * Hi there,
 * You need to return the output. Not echo it. Rule of thumb.
 * * Filters require a return value. If it’s a filter, you MUST return something
   *
   Actions don’t expect a return. Do whatever you want.
 *  Plugin Author [lukerollans](https://wordpress.org/support/users/hellolukerollansme/)
 * (@hellolukerollansme)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080421)
 * If you would like to donate, head on over to [https://plugify.io](https://plugify.io)
   and click the Donate button in the Clean Testimonials section 🙂
 * Regardless, would be more than happy to continue to help you out.
 *  [tdmohr](https://wordpress.org/support/users/tdmohr/)
 * (@tdmohr)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080478)
 * Hi Luke,
 * Thank-you for the great plugin. It really is exactly what I was looking for!
 * I know you don’t want to provide any support on this but I just wanted to mention
   that I am also having problems getting the filter example you posted above to
   work.
 * Displaying a testimonial via shortcode or widget simply do not appear to fire
   the ct_before_render_testimonial event. Either that or the example posted is 
   not being correctly parsed in my functions.php file. Other filters I have implemented
   are working properly though…
 * Can you please confirm that this should be working under wordpress 3.9.1?
 * I would love to properly customise the output of the testimonial without hacking
   the class.wp-testimonial.php file.
 * Thanks for any advice you can provide,
    Tim

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Example of function implementation’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/clean-testimonials_fcfcfc.svg)
 * [Clean Testimonials](https://wordpress.org/plugins/clean-testimonials/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/clean-testimonials/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/clean-testimonials/)
 * [Active Topics](https://wordpress.org/support/plugin/clean-testimonials/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/clean-testimonials/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/clean-testimonials/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * 7 replies
 * 3 participants
 * Last reply from: [tdmohr](https://wordpress.org/support/users/tdmohr/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/example-of-function-implementation/#post-5080478)
 * Status: not a support question