A WordPress child theme is a theme that inherits the functionality of another theme, called the parent theme, and allows you to modify, or add to, the functionality of that parent theme.WordPress.Org Codex
Child theme system is one of reason that i am in love with WordPress You can change everything on a parent theme with a child theme but you dont have to if you dont want. Mostly you dont need a child-theme if your modification just needs CSS because theme have already Custom Css option. In this article, i will try to explain some example situations that you have to use child-theme.
You want to add / remove custom bootstrap styles
FirmaSite theme have default bootstrap style and 12 custom bootstrap styles from Bootswatch but theme is still supporting to add / remove custom bootstrap styles. So you can have unlimited styles for you or your clients. You can create a child-theme that removes all bootstap styles and adds only your special custom styles easily and, with FirmaSite’s amazing structure, all your theme will use your custom style only. Buddypress + bbPress too!
Where can you get custom bootstrap styles?
- You can try to find free bootstrap styles from Google.
- You can use theme generators like Lavish, PaintStrap or BootSwatchr. You can even use official bootstrap customizer.
- You can write your own. Careful: It needs advanced coding. If you want a start point, you can start to read Customizing Bootstrap
- You can buy bootstrap skins from theme markets like CodeCanyon or WrapBootstrap.
I prepared an example child-theme for you. You can download and inspect its codes for your project or directly you can edit it and make it your special theme!
Download: Example Child Theme
What this example child-theme do?
- I found a pink nature photo from Google and created a custom Bootstrap style with using Lavish and example child-theme is adding this style to Theme Styles and removes “Default” bootstrap style with this example function:
/* * This function adds our custom bootstrap styles to option list */ add_filter( 'firmasite_theme_styles', "firmasite_childtheme_example_style" ); function firmasite_childtheme_example_style($array) { // Remove "default" named bootstrap style unset($array["default"]); // You can add multiple custom theme style $newthemes = array( "pink" => __( 'Pink', 'example' ), ); // If you want to remove default styles comes with parent theme, use: // return $newthemes; return $newthemes + $array; } /* * This function adds our custom bootstrap styles' location url to theme settings */ add_filter( 'firmasite_theme_styles_url', "firmasite_childtheme_example_style_url"); function firmasite_childtheme_example_style_url($array) { // You can add multiple custom theme style $newthemes = array( "pink" => get_stylesheet_directory_uri() . '/assets/themes/pink', ); return $newthemes + $array; }
- You can make your custom bootstrap style selected when switched to this theme (You can use this example for changing other settings too. Be careful when changing those settings. )
/* * This function makes our custom bootstrap style selected when switched to this theme * You can use this example for changing other settings too. Be careful when changing those settings. */ add_action( 'after_switch_theme', 'firmasite_childtheme_change_style' ); function firmasite_childtheme_change_style() { // bug report / support: http://unsalkorkmaz.com/ // We got theme settings $settings = get_option( 'firmasite_settings' ); // We are setting selected style as one of our custom bootstrap style $settings["style"] = "pink"; // Now we are saving settings update_option( 'firmasite_settings', $settings ); }
- Theme adds some functions that i suggest you to have it in your child-theme. Inspect
functions/child_theme.php
file in example theme for more details.
I will give more example child-themes in future like;
- If you want to change theme’s functionality (add, remove or modify theme options)
- If you want to change your custom post types templates. (Theme is using post type’s template as default for all custom post types but you can easily add your own templates)
Perhaps the current themes should take advantage of BootstrapCDN
Congrat for this great theme, I’m currently testing it.
Cheers,
We can easily set style location with firmasite_theme_styles_url filter. There is example function above
I think this function should be included in the main theme. By the way, congratulations to be an expert. You really deserve review on main wordpress website.
Ty. You can send a review in http://wordpress.org/support/view/theme-reviews/firmasite if you want. It means a lot for new users that thinking to use theme.
Very nice theme! Easy to set up and it meet all current standards and needs for good looking and functional website build with WordPress (and BuddyPress too). I am currently using it on my very popular Video Recipes blog http://recipetv.org and some others too.
Thank you for sharing this great work! Appreciate your time spent on this project.
Np. You can send a review in http://wordpress.org/support/view/theme-reviews/firmasite if you want. It means a lot for new users that thinking to use theme.