How To Create WordPress Child Theme – TwentyFifteen Theme

In this video, You will learn how to create WordPress Child Theme for Twenty Fifteen theme. We are going to learn how to remove Powered by WordPress link from the from WordPress Twenty Fifteen theme footer area and add a new widget area in the footer section.

You will learn

  • how to remove powered by WordPress link from the footer
  • How to add new widget area in the footer.

How To Create TwentyFifteen WordPress Child Theme

Create a new folder and save it as twentyfifteen-child. In this new folder, create three new files.

  • style.css
  • functions.php
  • footer.php

Step 1: Add following code in style.css file.

/*
Theme Name: Twenty Fifteen Child
Description: A child theme for my blog
Author: Tahir Taous
Author URI: http://justlearnwp.com
Version: 1.0
Template: twentyfifteen
*/

Step 2: Open functions.php file and add following code in it.

<?php

// Enqueue parent and child them stylesheet
function theme_enqueue_styles() {
    $parent_style = 'parent-style';
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style )
    );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

// Add support for new widget area

register_sidebar( array(
    'name'          => __( 'Widget Area in the Footer', 'twentyfifteen' ),
    'id'            => 'sidebar-2',
    'description'   => __( 'Add widgets here to appear in your sidebar.', 'twentyfifteen' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget'  => '</aside>',
    'before_title'  => '<h2 class="widget-title">',
    'after_title'   => '</h2>',
) );

Step 3: Add following code in the child theme’s footer.php file and save changes.

<?php
/**
 * The template for displaying the footer in child theme
 *
 * Contains the closing of the "site-content" div and all content after.
 */
?>

    </div><!-- .site-content -->

    <footer id="colophon" class="site-footer" role="contentinfo">
        <div class="site-info">
            <?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
            <div id="widget-area" class="widget-area" role="complementary">
                <?php dynamic_sidebar( 'sidebar-2' ); ?>
            </div><!-- .widget-area -->
        <?php endif; ?>
        </div><!-- .site-info -->
    </footer><!-- .site-footer -->

</div><!-- .site -->

<?php wp_footer(); ?>

</body>
</html>

That’s all. You have successfully created Twenty Fifteen child theme. Now you can upload this theme to your website.

Login to your WordPress dashboard, go to Appearance > Themes, upload and activate your theme.


You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *