Support » Plugins » Hacks » Customize the HTML output for Testimonials Widget via funtions.php filter?

  • Please see this thread below for the gist of what I’m trying to accomplish. I can’t possibly be the first person to do this, but I can’t find a detailed tutorial anywhere! The developer’s FAQ isn’t of much use to someone who doesn’t know PHP.

    The developer sort of pointed me in the right direction, but I don’t think he will help me any further than this without me paying him. 😀
    I’m still rather vague about what exactly I need to do here beyond “make a custom filter in your theme’s functions.php”

    I would expect a chunk of code that goes something like this, where I could simply copy and paste to re-order them and get the output order that I want (pseudocode):

    [testimonial text div]
    [title text div]
    [testimonial name div]

    I’ve spent quite some time poring over the default plugin code, but I have no idea where to even begin with this.

    Any help would be hugely appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    It doesn’t work quite how you think. Your filter function will be passed the entire HTML content of the testimonial as a single string. You will need to use PHP search and replace functions to find the proper span element, extract it from the content, and reinsert it in its new location.

    See Plugin_API#Filters for info on hooking into filters. Don’t worry about the plugin part, it will work from functions.php as well. The author correctly told you to not alter plugin files. You should not alter theme files for the very same reason. You should really create a very basic child theme which need not contain much more than your filter function. See Child Themes for info on that aspect.

    If you know any kind of programming, you can probably figure this out. Unfortunately, getting a reliable search and replace routine set up is a bit much of an ask for free coding advice, but not completely hopeless. To be clear, I am not asking for payment in exchange for this advice, I’m just giving you my assessment of the task’s scope. Good luck.

    This thread seems somewhat related to what you want to do.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customize the HTML output for Testimonials Widget via funtions.php filter?’ is closed to new replies.