Create WordPress Twenty Fifteen Child Theme :
WordPress twenty fifteen child theme allow you to make modifications without touching the parent theme’s code, which builds it easy to update your parent theme without erasing your changes.By creating a twenty fifteen WordPress child theme, you create a separate set of files that you can use to customize the theme without affecting the original theme at all.
Also see: How to Customize WordPress twenty fifteen theme - [video]
Getting Started :
Open the themes directory of wp-content/themes using cPanel. Within your new theme folder, create a file called style.css, this is the only file required to make a child theme and fill in the information as outlined below. The theme Name, URI, Description , Author and template.You can change each of the lines to suit your theme, but you must keep Theme Name and Template lines as well as the @import section.
/*
Theme Name: 2015 Child Theme
Theme URI: mygenesisthemes.com
Description: My own Twenty Fifteen Child Theme
Author: Syed Bavajan
Template: twentyfifteen
*/
@import url('../twentyfifteen/style.css');
/* Theme customization starts below this line -------- */
In the above code, you can change or remove any field, but don't touch theme name, template and @import options.
Now log in to your WordPress admin, go to Appearances > themes.Activate 2015 child theme.
Modifying Twenty fifteen child Theme CSS :
If you want to modify twenty fifteen child theme’s CSS, you can add CSS in the end of the style.css file and save it. These CSS lines will overwrite the parent twenty fifteen theme CSS.
Here if you don't want to display post metadata and post info, add the following code to your WordPress twenty fifteen child theme's CSS file.
.entry-footer {
display:none !important;
}
After adding this code, your child theme's CSS looks like
Theme Name: 2015 Child Theme
Theme URI: mygenesisthemes.com
Description: My own Twenty Fifteen Child Theme
Author: Syed Bavajan
Template: twentyfifteen
*/
@import url('../twentyfifteen/style.css');
/* Theme customization starts below this line -------- */
.entry-footer {
display:none !important;
}
Editing functions.php file :
if you need to add more custom functions to your theme then you can do so by creating a new functions.php file within your twenty fifteen child theme folder.This functions.php file should start with a php opening tag and end with a php closing tag.
<?php
// php code goes here
?>
Some useful functions.php tutorials :
To remove comment form HTML tags and attributes, add the following code to your twenty fifteen child theme's functions.php file
// remove comment form html tags and attributes
function remove_comment_form_allowed_tags() {
add_filter('comment_form_defaults','wordpress_comment_form_defaults');
}
add_action('after_setup_theme','remove_comment_form_allowed_tags');
function wordpress_comment_form_defaults($default) {
unset($default['comment_notes_after']);
unset($default['comment_notes_before']);
return $default;
}
To speed up your WordPress site even more, avoid css @import by adding the following code to your twenty fifteen child theme's functions.php file and remove @import url('../twentyfifteen/style.css'); from your child theme's CSS file
// avoid @ import
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
To show only one category posts on home page, then add the following code to your child theme's functions.php file and replace category ID number(6) with your own category ID.
add_action( 'pre_get_posts', 'one_category_home_page' );
function one_category_home_page( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '6' );
}
}
Editing other theme files :
Twenty fifteen theme’s other PHP files aren’t imported automatically. Other PHP files are edited by replacing the file with a copy.If you are planning to make changes to Twenty fifteen’s footer.php file, you would need to first make a copy of the old file and paste it into your twenty fifteen child theme.
Hopefully now you are able to create a WordPress twenty fifteen child theme and make the customization that you like.