How to Create a Child Theme in WordPress

How to Create a Child Theme in WordPress

WordPress makes it easy for you to quickly create your own custom child themes for customizing your themes to meet your own website needs. In this step by step video tutorial, I show you how to create a child theme using twentyfifteen theme while using the best practices for Theme Development.

Video Tutorial Showing How to Create a Child Theme in WordPress

Sample WordPress Filters and Functions for you to Use in Your New Custom Child Theme

When creating your own custom WordPress child themes, consider using these within your functions.php file:

//allow shortcodes in widgets
add_filter('widget_text', 'do_shortcode'); 

/*remove the default URL field from WP-comments form*/
function rankya_disable_comment_url($fields) { 
    return $fields;

/*Let's also add itemprop for < a for post link navigation links as they are important part of WP blogging and Google to follow*/
add_filter('next_post_link', 'post_link_attributes');
add_filter('previous_post_link', 'post_link_attributes');
function post_link_attributes($output) {
	$searchfor = '<a href='; 
	$replacewith = '<a itemprop="url" href=';
    return str_replace($searchfor,$replacewith,$output);

/*USE THIS FOR ITEMPROPs on links in Text Editor. For example, when inserting internal links or external links, you can use itemprop url*/
function rankya_tinymce_config( $init ) {
	$valid_a = 'a[accesskey|charset|class|contenteditable|contextmenu|coords|dir|download|draggable|dropzone|hidden|href|hreflang|id|lang|media|name|rel|rev|shape|spellcheck|style|tabindex|target|title|translate|type|onclick|onfocus|onblur|itemprop]';
	// Add to extended_valid_elements if it alreay exists
	if ( isset( $init['extended_valid_elements'] ) ) {
		$init['extended_valid_elements'] .= ',' . $valid_a;
	} else {
		$init['extended_valid_elements'] = $valid_a;
// Pass $init back to WordPress
	return $init;
add_filter('tiny_mce_before_init', 'rankya_tinymce_config');

These sample codes can be placed within functions.php for your WordPress Child Theme. I’ve got more complex and useful functions, if you are interested in learning more, simply comment using the form below

Author: RankYa

Online Entrepreneur, Qualified Web Developer, Google AdWords and Google Analytics Professional. Specialist in: Google SEO, Website Optimization, WordPress, Structured Data, JSON-LD, Microdata, Microformats, RDF, Vocabulary, HTML5, Advanced Image Optimization, Google Search Console, Google Webmaster Guidelines, Social Media Marketing, Facebook marketing and YouTube video ranking.

Thank you for sharing this blog post. Description: 'How to Create a Child Theme in WordPress is explained, step by step instructions for creating child theme in WordPress. Includes sample PHP codes for you'