I frequently get asked to work on Woo products. For awhile it was modifying their WordPress themes, and then Woo Commerce. Now their business has strongly shifted from themes to plugins. Their plugins generally work fine, but with countless customers, there will always be some who need some additional help. In my travels, the changes people want tend to fall into these categories, in increasing order of difficulty:
- Appearance changes to match the theme they are using.
- Structural changes in pages that show Woo output.
- Programming and functionality changes.
Note: the following procedure requires some file editing, file transfers, a willingness to edit some code, some WordPress skills, and a general understanding of how a webpage is constructed. If that gives you the heebie jeebies, get help from a developer.
I’ve had a number of requests to work on Sensei, their plugin for putting online courses onto your site. Most were for appearance changes, but my design colleague and tutorial expert Rob Cubbon wanted to have some user interaction on his lesson pages. In the WordPress backend, if you go to Sensei… Settings, and click on Lessons at the top, you’ll see this setting:Â Allow Comments for Lessons
That should be ticked/checked, and it was on his site.Â So far everything looked fine. He and some users had made some comments, which were visible in the WordPress back end, but the problem was that they weren’t displaying on the lesson pages!
Doc – What’s Up?
Then this helpful bit of Woo Sensei theming documentation came in handy (look for “Single Lesson”). Â I could have worked it out by hunting through code, but this saved time. I have to credit Woo with having pretty nice documentation. Many theme companies, including some with nicely-coded themes, have sucky documentation.
Warning: the following procedure requires some web development skills. Unless you’re very comfortable editing theme PHP code, hire a developer to do this!
That reminds me of another project – I was working with a very pretty commercial theme one time, and the client wanted significant changes. I asked the theme company if they had included any programming hooks or filters, and their bafflement made it seem like I had asked them to go fishing and smoking. They went off my recommended companies list, stat.
I thought of the following obvious WordPress template bit of code for comments, but that didn’t do anything when I popped it in for a test.
I suppose I should have expected that, given that the form had appeared before, and some comments were entered but just didn’t display.
Sensei’s Martial Plan
Though some pretty good documentationÂ exists for Sensei theming, for some reason they removed the part that explains how to safely make changes to Sensei templates. Weird! Fortunately, I had learned that the plugin’s templates were helpfully contained in the /templates folder in the Sensei plugin. I also knew that these plugin templates could be edited safely by putting a copy into my child theme, thus not changing core plugin code, so I made a copy of /templates/single-lesson.php, edited it, and put it into my child theme’s /sensei folder. This is a very handy way to allow a safe code override, and I applaud any plugin developer who allows that!
Because the normal comments template code didn’t do anything, I assembled a more manual method of displaying comments instead:
The above code should be pasted into single-lesson.php (in your child theme as per above) Â just before this line:
do_action( 'sensei_single_main_content' );
The comments immediately showed up! On this theme, my new markup looked pretty bare, so I added a pinch of styling for it. Obviously the CSS context of your theme will vary, but I hope this gives you an idea of what can be done. Here’s one of the places where this is working on Rob’s lesson site.
Turn It On Again With Genesis
My client’s theme was a Genesis theme, so there may have been some incompatibility with its own comment code. I may tear apart more code to find the root cause of this, especially if anyone expresses a strong interest.
One Singular Silenced Sensei-tion
I was asked to work on a site using “One”, yet another popular & enormous Themeforest theme.Â My client had implemented my suggestion above, which had produced a whole bunch of crummy looking output. (Doh!) Taking a close look, it turns out that the existing comments were appearing twice, and the second bunch had no CSS styling. So instead of no comments at all, the comments themselves were cloned, yet the comment response form was missing!
Now that’s not very sociable! So I went about looking for the reason. In many WordPress themes, a theme geek can find lots of clues in the theme’s files. In most child themes, if you want to change some behavior of the parent theme, you can safely do that by copying parent theme files to the child theme and modifying them. This theme objected to that, crashing impressively. As I recall, the duplicate file had some hard-coded includes that bombed when executed from the child theme folder. I also found a huge code framework in the parent theme. I’m sure this helps the original developers, although it hinders people trying to modify the theme (possibly by design).
I know, I’ve just lost many of you. 🙂 Â In English, this means that the One theme code is not trivial to modify, even for a theme geek.
After pawing through reams of code, I finally found a way in. Using a different Sensei programming hook, I managed to slip in the comment form like so:
Just like the code further above, this will go into your copy of single-lesson.php that you’ve put into your child theme, just before the line that says:
do_action( 'sensei_single_main_content' );
But Wait, There’s More – A Private Message
There’s one more area where the comment form was missing from “One” but was desired… this was the screen where the teacher is responding to a student’s private message. I tracked that down to another Sensei template file, content-single-message.php. Since this file does not seem to appear on Woo’s documentation site, instead of publishing the contents of the file, I’ll just say that you want to include the following line in your copied template file, just after the line that contains “the_content”.
Alert readers trying this will notice that the comment form appears above the existing comments instead of below (the normal way). This is a restriction due to One’s custom template structure. Anyone wanting to hack One to get it below existing comments can certainly try that, although that’s even more work, and may possibly void your “One” theme support or botch upgrades they have if you edit their core code. Or just keep harassing the “One” developers until they help. 🙂
Props go to Vitruvian Studio. Check them out for a variety of courses in drawing, painting, and other art topics, both online and in their Chicago area location!
I certainly haven’t tested my ideas above in every theme out there, but I think my code could be useful for various themes that are also shy about showing Sensei comments. Please let me know how you make out in the comments below!