Build and use a child theme so you can customize safely while keeping core theme updates simple and low risk.
Child theme in osclass (as in wordpress, prestashop or other classifieds scripts) is tool that allow to modify theme without affecting original theme. Child theme allows to update original theme, without affecting your modifications. Objective of child theme is not to replace everything, but allow slightly modifications in particular files, it's good to note that child theme will contains only files those should be replaced or modified.
Make sure to check our CSS customization guide with simple examples: https://docs.osclasspoint.com/customizations-of-theme-basic
We will need several files to create our blank child theme, for next of this article we will be using Gamma Osclass Theme and will try to create Gamma Child Osclass Theme.
<?php
/*
Theme Name: Gamma CHILD Osclass Theme
Theme URI: https://osclasspoint.com/
Description: Responsive fast and clean premium osclass theme
Version: 1.0.0
Author: MB Themes
Author URI: https://osclasspoint.com
Widgets: header,footer
Theme update URI: gamma-osclass-theme
Product Key: GFE1crrhnvi0AtRiagJp
Parent Theme: gamma
*/
?>
Child theme is created and ready to use activate from oc-admin! Keep in mind you cannot remove parent theme when using child theme. This step is last in most of tutorials, but what you should do next? Noone knows that even osclass docs does not provide more details.... so let's continue!
There are few things to remember when working with your child theme.
Let's do something on example. Our objective is:
Stylesheet is referenced from head.php, this file from header.php and header is called from each file, so creating custom head.php does not make sense. Rather then we will create function to add our stylesheet via hook from functions.php
function gam_child_custom_css() {
osc_enqueue_style('style-child', osc_current_web_theme_url('css/style-child.css'));
}
osc_add_hook('header', 'gam_child_custom_css') <link href="https://dev3.abprofitrade.eu/oc-content/themes/gamma/css/style-child.css" rel="stylesheet" type="text/css" />
Now we will update footer.php to have custom footer on home page. Note if you would like to have custom footer in all the pages, you would repeat bellow procedure for every file in theme.
<?php osc_current_web_theme_path('footer.php'); ?> <?php include osc_base_path() . 'oc-content/themes/gamma_child/footer.php'; ?>
<footer>Hello world footer!</footer>
Your footer is now updated.
We will now update home page and put there own text or block.
Your home page is now updated.
We have created custom child theme in classifieds, can now freely update our parent theme etc... however there some questions unanswered:
Basically we recommend to use child themes just for custom stylesheets, javascripts and functions to be added via hook, hence copying all the files from parent into child and updating it all the time there is new update in parent is making usage of child theme useless. Before using or bying your classifieds theme make sure it match your expectation and avoid redeveloping it from scratch, as it may be contra productive.
After setup, use translating themes and plugins. Preview free layouts on our free themes demo site.
Question: How do I create a Gamma child theme in Osclass without copying the parent?
Answer: Copy only the files you override. Create oc-content/themes/gamma_child, copy index.php and screenshot.png from Gamma, and set Parent Theme: gamma in the header. Activate the child in Appearance. Keep the Gamma parent installed so files you did not copy still load. A full copy stops parent updates from applying.
Question: Why can I not delete OsclassPoint Gamma theme while gamma_child is active?
Answer: Keep Gamma installed while gamma_child is active. Osclass loads missing files from the parent, so deleting Gamma leaves templates with no fallback. The child should hold only overrides. Copy one file at a time. Parent updates then still apply to files you did not place in the child folder.
Question: How do I add style-child.css to an OsclassPoint Gamma child theme?
Answer: Create functions.php in gamma_child and hook osc_enqueue_style on header so Osclass loads css/style-child.css from the child. Put the file in oc-content/themes/gamma_child/css/. Do not copy parent head.php only to add a stylesheet. Gamma updates then keep applying to files you did not override.
Question: What happens if I replace footer.php in an Osclass child theme?
Answer: Copy footer.php into the child and make templates load it with osc_current_web_theme_path so Osclass checks the child folder first. On older Osclass, a raw include of the parent footer can ignore the child file. Osclass 8.0 hard-checks the child with that helper. Copy only the files you override.
Question: Can I keep the same PHP function name in an OsclassPoint Gamma child theme?
Answer: Rename a Gamma function if you copy it into the child, then update every call in that file. PHP function names must stay unique. Leaving the original name causes a cannot redeclare fatal error because the Gamma parent already declared it. Copy only the override file that needs that function.
Question: Why does copying every OsclassPoint Gamma file into the child make it useless?
Answer: Put only overridden files in gamma_child so Gamma updates still apply. A full copy means every update must be merged by hand. Start blank and copy one file at a time. Parent templates you did not copy keep loading from Gamma. That is the point of a child theme.