Advanced
How to customize your javascript and CSS files
How to customize your javascript and CSS files
Omega comes bundled with a child theme. Once you unzip the .zip
file that you have downloaded from Themeforest, you will see
omega-child-theme-ver.zip.
A child theme is a theme that inherits the functionality of another theme, called the parent theme. Child themes allow you to modify, or add to the functionality of that parent theme. A child theme is the best, safest, and easiest way to modify an existing theme, whether you want to make a few tiny changes or extensive changes. Instead of modifying the theme files directly, you can create a child theme and override within.
Here are a few reasons:
If you want to change more than just the stylesheet, your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the
parent theme directory when your site loads. For instance, if you want to change the PHP code for the site header, you can include a header.php in your child theme's directory, and that file will be used instead of the
parent theme's header.php.
You can also include files in the child theme that are not included in the parent theme. For instance, you might want to create a more specific template than is found in your parent theme, such as a template for a specific
page or category archive.
Unlike style.css, the functions.phpof a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.)
In that way, the functions.phpof a child theme provides a smart, trouble-free method of modifying the functionality of a parent theme. Say that you want to add a PHP function to your theme. The fastest way would be to open its functions.phpfile and put the function there. But that’s not smart: The next time your theme is updated, your function will disappear. But there is an alternative way which is the smart way: you can create a child theme, add a functions.phpfile in it, and add your function to that file. The function will do the exact same job from there too, with the advantage that it will not be affected by future updates of the parent theme. Do not copy the full content of functions.php of the parent theme into functions.php in the child theme.
The structure of functions.phpis simple: An opening PHP tag at the top, and below it, your bits of PHP. In it you can put as many or as few functions as you wish. The example below shows an elementary functions.phpfile that does one simple thing: Adds a favicon link to the head element of HTML pages.
<?php // Opening PHP tag - nothing should be before this, not even whitespace
// Custom Function to Include
function favicon_link() {
echo '<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />' . "\n";
}
add_action( 'wp_head', 'favicon_link' );
TIP FOR THEME DEVELOPERS:
if ( ! function_exists( 'theme_special_nav' ) ) {
function theme_special_nav() {
// Do something.
}
}
In that way, a child theme can replace a PHP function of the parent by simply declaring it beforehand.
Omega comes with a minifiedand an unminifiedversion of its main javascript file, theme.min.js and theme.js respectively. There is also a map.min.jsand a map.jsfile provided. They are located in the assets/jsfolder. If you want to edit the javascript of your theme do the following:
theme.js
file that you want to customize.theme.min.js
file that is enqueued to be the theme.js
unminified version, around
line 201.If you want to edit the map javascript of your theme do the following:
map.js
file that you want to customize.map.min.js
file that is enqueued to be the map.js
unminified version, around
line 2271.Omega comes with a minifiedand an unminifiedversion of its main CSS file, theme.min.css and theme.css respectively. There is also a bootstrap.min.cssand a bootstrap.cssfile provided. They are located in the assets/cssfolder. If you want to edit the CSS of your theme do the following:
theme.css
file that you want to customize.theme.min.css
file that is enqueued to be the theme.css
unminified version, around
line 218.If you want to edit the bootstrap CSS of your theme do the following:
bootstrap.css
file that you want to customize.bootstrap.min.css
file that is enqueued to be the bootstrap.css
unminified version, around
line 217.