Fred, functions.php is a file in your theme, not in the plugin directory. You will need to copy that code only if you update your theme. To ever need to worry about it, you could create a child theme for your theme and put the code in there
Yannick,
In reading back, I discovered that the file I was looking for was in my theme’s directory.
I guess I am good to go.
Regards,
Fred
Hi, Yannick,
Apparently I lost your code when my theme was updated. I noticed that it wasn’t sorting correctly when I looked at the table.
So I pasted your code into the end of the functions.php file and uploaded it to my site.
Problem corrected.
I was toying with the idea of putting your code into a separate file and then using the ‘include’ function. Then I would only have to add three lines after a theme update. Like this:
<?php
include ‘sorting.php’;
?>
Sorting would be the file I would paste your code into.
Do you see any issues with that?
Regards,
Fred
Hi Fred, Sorry, I should have been more explicit. Whenever you have custom code to put in your theme, you should create a child theme. A child theme inherits all of the files from a parent theme, but lets you add your own custom code elements in functions.php file that is separate from the parent theme functions.php. Just look up tutorials on how create a child theme and you’ll be update-proof.
Yannick,
I got as far as creating the ‘-child’ subirectory under themes and copying the style.css and functions.php files into the child theme directory.
I am having trouble figuring out where to past the suggested coding into the functions.php file. The theme I am using uses the ‘get_stylesheet’ code.
When I look at the Themes page back on my back end, it says that the child theme is incomplete.
Any idea what I am overlooking?
Regards,
Fred
Hi Fred, You should not be copying the style.css and functions.php into the child theme directory. As the instructions show, you should be creating a new file called style.css and putting a header similar to the one shown. Of course, you should change the Template for the name of the parent theme directory.
Your functions.php file should also be a new empty file. This file will contain a bit of code to load the parent stylesheet, along with the few segments of custom code I gave you.. Perhaps this tutorial is better explained than the one you found: https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/
Hi, Yannick,
Try as I might, I couldn’t make it work.
So I cheated a bit.
I installed a plugin called ‘Child Theme Configurator’.
I created the child theme using it.
Then, I pasted your code into the newly created functions.php which were complements of this plugin.
Works like a champ.
Cannot figure out what I did wrong.
I deleted your code from the parent theme.
I am running the child theme now. It is looking good. And the table is sorting correctly.
Thanks for pointing me in the right direction.
Regards,
Fred
Hi Fred, Glad you found a solution to be able to create a child theme. That’s actually an interesting plugin you found. I mentioned it to one of my friends who always asks me to help her create child themes.