This may seem a backward step from my WordPress theming projects, where I am trying to customize that at a per-site basis with just Custom CSS- I am working on a new one using the Galactic theme I have done for a few presentations rigged as a WordPress site (e.g. This is Not a Blog, Cool Web Stuff, a UDG Agora presentation at OpenEd15, etc).

I like this because the Presentation Can Be The Resource Site, rather than separating slides from a collection of reference links.

Anyhow, I stumble some into minor things I know I can tweak if I edit the theme. One approach would be to wrap the custom code into a plugin. But sometimes they are pretty minor, some WordPress actions I might need just like 5 lines in functions.php to make it happen.

My example today is I want to use the comments form in one I am prepping for Friday tomorrow, but I dislike the default WordPress title for the comments box.

comment-before

I don’t want people to add/leave a reply, I want them to add more examples to my collection of “web tricks”. Why should it be so hard to change that title?

All of the suggestions for how to customize this (and something I have done in my own custom projects) is to manually edit the theme files. If I did it as a plugin, I’d either have to hard code the changes I want, or battle with setting up an options screen so the custom text can be entered. Seems like a lot of work.

Enter a new solution, the My Custom Functions WordPress plugin – it does the same thing a lot of my modifications do, it just adds code to the theme’s functions.php set without having to edit it (and risk loss when the theme is updated- NEVER EDIT THE THEMES!).

Now this does mean having to write code, so if this horrifies you, please exit the blog, now. Thank you.

But I have now, in my dashboard, a place to add this small function which calls the WordPress thingy that generates the comment form, and changes not only the title, but the text on the menu.

custom functions

If you care to read the code not from an image, here it is (and it has ATTRIBUTION! h/t is “hat tip”)

function comment_reform ($arg) {
// --- h/t https://wordpress.org/support/topic/how-to-change-wording-of-leave-a-reply#post-1881213
	$arg['title_reply'] = __('Add a Trick?');
	$arg['label_submit'] = __( 'Share it!' );
	return $arg;
}
add_filter('comment_form_defaults','comment_reform');

And now my comment form is displayed the way I want it.

after

Now here is where it gets even better. In a multisite, if I did this via child themes, I would need different child themes if I wanted a different customization on the comment form. But with this plugin, it’s done at the site level, so I could have different custom code for the same theme on different sites.

If your eyes are as glazed as the photo above of Princess Alexandrine, well sorry. But this is super useful and I am just starting to see possibilities. A lot of modifications I want for a site only involve adding stuff to the functions.php area (not changing any of the output templates).

Anyhow, I can now do this without having children. Not that I don’t love kids (you do realize I am talking about WordPress Child Themes, right? Bueller? Bueller?…) They are useful as an opposable thumb, but sometimes not necessary.)

Anyhow, each time a scrape a tad deeper in WordPress, I find little interesting doorways.


Top / Featured Image: Looking for images to represent the idea of “childless” wordpress theming, led to bizarre places, ending here with a photo of Swedish Princess Alexandrine of Baden. The Duchess of Saxe-Coburg and Gotha married some scoundrel named Ernest, and they never had children. She looks rather dowager-y in this Public Domain photo from Wikimedia Commons

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. What a nice thing. The companion to the jetpack CSS editor which I’ve been finding handy especially on multi-site where u can’t add/edit themes. Could save a ton of time making a child theme for a few lines.

Leave a Reply to John Cancel reply

Your email address will not be published. Required fields are marked *