{"id":303,"date":"2022-07-05T11:23:07","date_gmt":"2022-07-05T11:23:07","guid":{"rendered":"https:\/\/rizkiakmanda.com\/?p=303"},"modified":"2022-07-04T11:27:39","modified_gmt":"2022-07-04T11:27:39","slug":"wordpress-child-theme","status":"publish","type":"post","link":"https:\/\/rizkiakmanda.com\/?p=303","title":{"rendered":"WordPress Child Theme"},"content":{"rendered":"<h3><b>Apa itu WordPress Child Theme?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Seperti namanya, child theme yang berarti juga tema anak adalah turunan atau tema yang mewarisi seluruh code dan fungsi dari tema induknya atau tema utama. Fungsi dari child theme itu sendiri adalah untuk memungkinkan Anda memodifikasi, menambah fungsi tema utama atau juga merubah style dari tema utama tanpa harus menyentuh satupun file di theme induk.<\/span><\/p>\n<h3><b>Mengapa harus Child Theme?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Mengapa harus repot-repot menggunakan child theme bila Anda bisa langsung mengubah atau menambahkan sesuatu di theme induk? Anggap Anda menggunakan tema komersil yang disediakan dari WordPress ORG sebagai tema utama Anda saat ini. Lalu Anda ingin mengubah bentuk tampilan post Anda menjadi seperti yang Anda inginkan. Anda mengubahnya di tema utama dan berhasil, lalu beberapa hari kemudian tema tersebut memiliki update terbaru, entah itu memperbaiki bugs, update keamanan ataupun hanya menambahkan warna.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Lalu Anda meng-klik update pada tema yang sudah Anda ubah sebelumnya. Maka semua perubahan itu akan hilang, terganti oleh update, kembali menjadi tema utama dasar aslinya. Adapun Anda melakukan update manual seperti menyamakan perubahan dan melihat apa saja yang diubah untuk berikutnya Anda tambahkan satu persatu ke tema Anda, bukankah itu lebih memakan waktu dan berpotensi error lebih besar?<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Maka seperti yang dijelaskan di atas tadi, Child Theme berfungsi sebagai \u201cpenambah\u201d untuk tema utama Anda tanpa harus menyentuh file di tema utama. Jika Anda melakukan perubahan dan penambahan di Child Theme, maka saat tema utama Anda update, perubahan tersebut tidak akan hilang.<\/span><\/p>\n<h3><b>Cara membuat child theme<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Pertama, pastikan Anda memiliki akses ke File Manager dalam server website Anda atau akses ke FTP. Kemudian masuk dalam direktori wp-content &gt; themes. Temukan nama tema yang hendak Anda tambahkan child theme nya.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-304 alignnone\" src=\"https:\/\/rizkiakmanda.com\/wp-content\/uploads\/2022\/07\/child-theme1.png\" alt=\"\" width=\"242\" height=\"194\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Setelah membuat folder seperti gambar diatas, Anda harus menambahkan file baru di dalam folder child theme, file yang harus ditambah yaitu:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">style.css<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">function.php<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">screenshot.png (dapat mengambil dari folder tema utama)<\/span><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3><b>Stylesheet (style.css)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Style pada child theme umumnya mengambil bawaan dari tema utama, karenanya isi child theme style selalu kosong. Dari sini Anda dapat menambahkan style baru atau menimpa style yang sudah ada di tema utama.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Isi dari file style.css dalam child theme biasanya hanya <\/span><i><span style=\"font-weight: 400;\">CSS comment<\/span><\/i><span style=\"font-weight: 400;\">:<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<div class=\"dm-code-snippet dark no-background  dm-slim-version\" style=\"background-color:#abb8c3;\" snippet-height=\"\">\n\t\t\t<div class=\"control-language\">\n                <div class=\"dm-buttons\">\n                    <div class=\"dm-buttons-left\">\n                        <div class=\"dm-button-snippet red-button\"><\/div>\n                        <div class=\"dm-button-snippet orange-button\"><\/div>\n                        <div class=\"dm-button-snippet green-button\"><\/div>\n                    <\/div>\n                    <div class=\"dm-buttons-right\">\n                        <a id=\"dm-copy-raw-code\">\n                        <span class=\"dm-copy-text\">Copy Code<\/span>\n                        <span class=\"dm-copy-confirmed\" style=\"display:none\">Copied<\/span>\n                        <span class=\"dm-error-message\" style=\"display:none\">Use a different Browser<\/span><\/a>\n                    <\/div>\n                <\/div>\n                <pre class=\"no-line-numbers\"><code id=\"dm-code-raw\" class=\"no-wrap language-css\"><\/p>\n<pre class=\"dm-pre-admin-side\">\/*\r\n Theme Name:   Tema Child\r\n Theme URI:    https:\/\/url-website.com\/\r\n Description:  Tema Child Theme Text\r\n Author:       Nama Anda\r\n Author URI:   https:\/\/url-website.com\/\r\n Template:     tema-prefix\r\n Version:      1.0.0\r\n Tags:         CSS tags\r\n Text Domain:  tema-child\r\n*\/\r\n<\/pre>\n<p><\/code><\/pre>\n\t\t\t<\/div>\n        <\/div>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Theme Name: Adalah nama tema child Anda. Disarankan agar memakai nama tema utama di depannya<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Theme URI: Alamat website dimana tema Anda digunakan<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Description: Text apapun yang mendeskripsikan tema child Anda<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Author: Nama pemilik tema, bisa memakai pemilik nama tema utama<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Author URI: Alamat website pemilik tema<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Template: Nama tema utama (bisa dilihat di folder wp-content &gt; themes)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Version: Versi child theme Anda<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Tags: CSS Tags untuk tema Anda, dapat menyamakan dengan tema utama<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Text Domain: Digunakan untuk translate, bisa disamakan dengan tema utama jika Anda tidak menggunakan prefix lain<\/span><\/li>\n<\/ul>\n<h3><b>File Fungsi Child Theme (function.php)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">File ini memiliki fungsi untuk memanggil child theme sebagai tema ekstensi dari tema utama. Bila Anda tidak memasukkan code ini di function.php, child theme tidak akan berjalan meski sudah diaktifkan.<\/span><\/p>\n<div class=\"dm-code-snippet dark no-background  dm-slim-version\" style=\"background-color:#abb8c3;\" snippet-height=\"\">\n\t\t\t<div class=\"control-language\">\n                <div class=\"dm-buttons\">\n                    <div class=\"dm-buttons-left\">\n                        <div class=\"dm-button-snippet red-button\"><\/div>\n                        <div class=\"dm-button-snippet orange-button\"><\/div>\n                        <div class=\"dm-button-snippet green-button\"><\/div>\n                    <\/div>\n                    <div class=\"dm-buttons-right\">\n                        <a id=\"dm-copy-raw-code\">\n                        <span class=\"dm-copy-text\">Copy Code<\/span>\n                        <span class=\"dm-copy-confirmed\" style=\"display:none\">Copied<\/span>\n                        <span class=\"dm-error-message\" style=\"display:none\">Use a different Browser<\/span><\/a>\n                    <\/div>\n                <\/div>\n                <pre class=\"no-line-numbers\"><code id=\"dm-code-raw\" class=\"no-wrap language-php\"><\/p>\n<pre class=\"dm-pre-admin-side\">function namatema_enqueue_styles() {\r\n \r\n    $parent_style = 'namatema-style'; \/\/ This is 'namatema-style' for the namatema theme.\r\n \r\n    wp_enqueue_style( $parent_style, get_template_directory_uri() . '\/style.css', array( 'namatema-plugin' ) );\r\n    wp_enqueue_style( 'child-style',\r\n        get_stylesheet_directory_uri() . '\/style.css',\r\n        array( $parent_style ),\r\n        wp_get_theme()-&gt;get('1.0.0')\r\n    );\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'namatema_enqueue_styles' );\r\n\r\n<\/pre>\n<p><\/code><\/pre>\n\t\t\t<\/div>\n        <\/div>\n<p><span style=\"font-weight: 400;\">Wp_enqueue_style berfungsi memanggil style child theme ke dalam website setelah theme diaktifkan. Di dalam array( \u2018namatema-plugin\u2019 ) harus diisi menggunakan salah satu nama style yang dipakai di dalam tema utama. Maka kemudian style child akan dipanggil setelahnya.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Atau bisa juga memakai kode ini:<\/span><\/p>\n<div class=\"dm-code-snippet dark no-background no-background-mobile dm-slim-version\" style=\"background-color:#abb8c3;\" snippet-height=\"\">\n\t\t\t<div class=\"control-language\">\n                <div class=\"dm-buttons\">\n                    <div class=\"dm-buttons-left\">\n                        <div class=\"dm-button-snippet red-button\"><\/div>\n                        <div class=\"dm-button-snippet orange-button\"><\/div>\n                        <div class=\"dm-button-snippet green-button\"><\/div>\n                    <\/div>\n                    <div class=\"dm-buttons-right\">\n                        <a id=\"dm-copy-raw-code\">\n                        <span class=\"dm-copy-text\">Copy Code<\/span>\n                        <span class=\"dm-copy-confirmed\" style=\"display:none\">Copied<\/span>\n                        <span class=\"dm-error-message\" style=\"display:none\">Use a different Browser<\/span><\/a>\n                    <\/div>\n                <\/div>\n                <pre class=\"no-line-numbers\"><code id=\"dm-code-raw\" class=\"no-wrap language-php\"><\/p>\n<pre class=\"dm-pre-admin-side\">function namatema_enqueue_styles() {\r\n \r\n    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '\/style.min.css' );\r\n    wp_enqueue_style( 'child-style',  get_stylesheet_directory_uri() . '\/style.css',  array( 'parent-style' ) );\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'namatema_enqueue_styles' );\r\n<\/pre>\n<p><\/code><\/pre>\n\t\t\t<\/div>\n        <\/div>\n<p><span style=\"font-weight: 400;\">Fungsinya sama, Anda hanya perlu mengganti nama file \u201cstyle.min.css\u201d untuk parent-style tergantung nama file yang ada di dalam folder tema utama.<\/span><\/p>\n<p><b>Aktivasi Tema Child<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Setelah membuat kedua file diatas beserta isinya, Anda hanya perlu mengaktifkan child theme Anda di dalam halaman admin WordPress website Anda. Kemudian buka menu Appearance &gt; Themes, cari nama child theme Anda lalu klik activate.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-308 alignnone\" src=\"https:\/\/rizkiakmanda.com\/wp-content\/uploads\/2022\/07\/child-theme2.png\" alt=\"\" width=\"512\" height=\"298\" srcset=\"https:\/\/rizkiakmanda.com\/wp-content\/uploads\/2022\/07\/child-theme2.png 512w, https:\/\/rizkiakmanda.com\/wp-content\/uploads\/2022\/07\/child-theme2-300x175.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apa itu WordPress Child Theme? Seperti namanya, child theme yang berarti juga tema anak adalah turunan atau tema yang mewarisi seluruh code dan fungsi dari tema induknya atau tema utama. Fungsi dari child theme itu sendiri adalah untuk memungkinkan Anda memodifikasi, menambah fungsi tema utama atau juga merubah style dari tema utama tanpa harus menyentuh [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":309,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[3,12],"tags":[],"class_list":["post-303","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-tutorial","category-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303"}],"version-history":[{"count":4,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/posts\/303\/revisions\/310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=\/wp\/v2\/media\/309"}],"wp:attachment":[{"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rizkiakmanda.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}