Digital experiences for all disciplines
New Landing › How can we help? › Cardinal › Child Theme usage?
New Landing › How can we help? › Cardinal › Child Theme usage?
- This topic has 7 replies, 3 voices, and was last updated 9 years by Swift Ideas – Ed.
-
Posted in: Cardinal
-
January 7, 2015 at 9:24 pm #139793
I’m working on customizations of this theme for a client and one thing they’d like done is to remove the ‘Posts tagged with’ text from archive pages.
Usually this is simply done by copying the page template to the child theme, editing the text and done.
However, that doesn’t seem to be the case here. The file used is in swift-framework>core>sf-page-heading.php. Copying the file structure to the child theme and editing the file does nothing.
What am I missing?
January 8, 2015 at 7:59 am #139875Hi
Any files beginning with sf- are framework files, and can’t be overwritten using that method.
You have to replace the function, by adding the whole function starting from the conditional statement, to you child theme’s functions.php file:
/* PAGE HEADING ================================================== */ if ( ! function_exists( 'sf_page_heading' ) ) { function sf_page_heading() {
Make sure you copy the whole function
– Kyle
February 2, 2015 at 7:57 pm #146488I have to ask – why would you do it this way, instead of putting it in the base functions file?
February 3, 2015 at 8:08 am #146595Because when you update the theme your change will be lost
– Kyle
February 3, 2015 at 9:30 am #146627No, no I wouldn’t. Putting the function in the root functions file, rather than nesting it in folders, would only make it easier to trace where functions are being generated.
If I copy that function to the Child theme function and modify it, then update the primary theme, the function is still there and nothing is lost.
So I’m a bit unclear where your answer came from. I guess I need to be more clear – why are these functions in nested folders, rather than in the root functions file? I’m really curious, as it seems to add an unnecessary level of complexity.
February 3, 2015 at 9:35 am #146630Sorry I thought you were asking me why to add it to the functions.php file in the child theme instead of the parent theme.
The answer to your question is organization. Adding all of the theme functions to the functions.php file would not be well organised at all and unless people knew the name of the function they wanted to change, then they would struggle to find it. We have different functionality for the theme, such as the swift framework, the theme options, the custom post types etc. It’s much better for us to organize this into folders
– Kyle
June 10, 2015 at 10:28 pm #183375I’m going to politely disagree with you. Your method makes it extremely difficult to trace file origins, much less being able to alter functions.
Putting all functions in the top level functions.php file and commenting to designate how and where they are used should be just as easy as ‘organizing’ them into separate files and subfolders.
You say
“unless people knew the name of the function they wanted to change, then they would struggle to find it. “
Well, I think it’s MORE of a struggle to find functions when they’re NOT in the functions.php file. If you have a single functions file, someone looking for a function has several options for searching (by function name, by parameter, by keywords they can find using web dev tools, etc) AND they have the confidence of knowing the function they’re looking for is in that file. Not only that, but they can easily change the function in the child theme.
As it is now, you have to use a tool like EasyFind (for Mac) to search through all the theme files to locate the function you’re looking for.
In any case – I wanted to reply to this with my own thoughts so that others may see there are different and possibly better approaches to doing things than what theme developers deem ‘right’.
June 11, 2015 at 8:10 am #183473Hi @grokism,
I can see your points, but for us it’s just not maintainable to have what would likely be a 30-40k line functions.php file. We share most functions across all of our latest themes so that we maintain a single codebase for the most part. This saves us a lot of time.
There are of course pros and cons for both methods, but for now this is the method that works best for how we are set up. I appreciate you taking the time to give some feedback.
– Ed
-
Posted in: Cardinal
You must be logged in to reply to this topic.