{"id":1125,"date":"2013-11-07T07:44:18","date_gmt":"2013-11-07T07:44:18","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=1125"},"modified":"2022-02-17T07:14:03","modified_gmt":"2022-02-17T07:14:03","slug":"create-a-child-theme","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/themes-wordpress\/child-themes\/create-a-child-theme","title":{"rendered":".Create A Child Theme"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Creating A Child Theme<\/h4>\n\n\n\n<p>This allows you to modify a main theme but still allow the main theme to be updated.<\/p>\n\n\n\n<p>The main guide:&nbsp;<a href=\"http:\/\/codex.wordpress.org\/Child_Themes\">http:\/\/codex.wordpress.org\/Child_Themes<\/a><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Creating The New Theme<\/h5>\n\n\n\n<p>1. Creat a new directory for the child theme, typcially &#8220;main_theme_name-child&#8221;<\/p>\n\n\n\n<p>2. Create a file called &#8220;style.css&#8221; and paste this into it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n Theme Name:     Twenty Thirteen Child\n Template:       twentythirteen\n*\/\n\n@import url(\"..\/twentythirteen\/style.css\");\n\n\/* =Theme customization starts here\n-------------------------------------------------------------- *\/<\/code><\/pre>\n\n\n\n<p>Change to match the theme you are making a child of.<\/p>\n\n\n\n<p>This css file is included after the parent theme so anything here will take precedence.<\/p>\n\n\n\n<p>3. Activate the child theme in wordpress.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Customizing other files<\/h4>\n\n\n\n<p>The child theme can overwrite any file in the parent theme simply by copying the file from the parent theme into the child theme directory and customizing it. &nbsp;That file will them be used instead of the parent theme&#8217;s header.php.<\/p>\n\n\n\n<p>You can also include files in the child theme that are not included in the parent theme. E.g. 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.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Functions.php customization<\/h4>\n\n\n\n<p>functions.php in a child theme is loaded&nbsp;in addition not instead of&nbsp;its counterpart from the parent theme.<\/p>\n\n\n\n<p>Basic empty file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n\n?><\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Customizing existing functions<\/h5>\n\n\n\n<p>A child theme\u2019s functions.php is loaded first means that you can make the user functions of your theme pluggable \u2014that is, replaceable by a child theme\u2014 by declaring them conditionally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ( ! function_exists( 'theme_special_nav' ) ) {\n    function theme_special_nav() {\n        \/\/  Do something.\n    }\n}<\/code><\/pre>\n\n\n\n<p>This way a child theme can replace a PHP function of the parent by simply declaring it beforehand.&nbsp;<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Doing things after the main themes functions.php file<\/h5>\n\n\n\n<p>For instance call&nbsp;set_post_thumbnail_size() to override its call of the function<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/----------------------------------------------\n\/\/----------------------------------------------\n\/\/----- DO AFTER MAIN THEME FUNCTIONS FILE -----\n\/\/----------------------------------------------\n\/\/----------------------------------------------\nadd_action( 'after_setup_theme', 'my_child_theme_setup', 11 );\t\t\/\/11=Run with a later priority\n\nif ( ! function_exists( 'my_child_theme_setup' ) ):\n\tfunction my_child_theme_setup()\n\t{\n\t\tif ( function_exists( 'add_theme_support' ) )\n\t\t{\n\t\t\t\/\/-----------------------------------------------\n\t\t\t\/\/----- OVERRIDE PARENT THEME SETTINGS HERE -----\n\t\t\t\/\/-----------------------------------------------\n\t\t\tadd_theme_support( 'post-thumbnails' );\n\t\t\tset_post_thumbnail_size( 200, 200, true );\n\t\t}\n\t}\nendif;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Creating A Child Theme This allows you to modify a main theme but still allow the main theme to be updated. The main guide:&nbsp;http:\/\/codex.wordpress.org\/Child_Themes Creating The New Theme 1. Creat a new directory for the child theme, typcially &#8220;main_theme_name-child&#8221; 2. Create a file called &#8220;style.css&#8221; and paste this into it: Change to match the theme [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126],"tags":[],"class_list":["post-1125","post","type-post","status-publish","format-standard","hentry","category-child-themes"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=1125"}],"version-history":[{"count":12,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1125\/revisions"}],"predecessor-version":[{"id":2842,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1125\/revisions\/2842"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=1125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=1125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=1125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}