{"id":11976,"date":"2026-11-15T03:17:38","date_gmt":"2026-11-14T20:17:38","guid":{"rendered":"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/"},"modified":"2026-11-15T03:17:38","modified_gmt":"2026-11-14T20:17:38","slug":"solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme","status":"publish","type":"post","link":"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/","title":{"rendered":"Solusi Jitu Mengatasi get_template_directory_uri ke Parent Theme"},"content":{"rendered":"<p>Saat mengembangkan kustomisasi tampilan pada <a href=\"https:\/\/wordpress.org\/\" target=\"_blank\" rel=\"noopener\">WordPress<\/a> menggunakan Child Theme, kendala <strong>get_template_directory_uri mengarah ke parent theme<\/strong> sering membuat file aset maupun modul tambahan gagal dimuat. Memahami <strong>Solusi Jitu Mengatasi get_template_directory_uri ke Parent Theme<\/strong> sangat krusial bagi <strong>Sobat JN<\/strong> agar pemanggilan stylesheet, script, maupun file fungsi kustom benar-benar mengarah ke direktori Child Theme yang sedang aktif, bukan kembali ke folder tema induk.<\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">Daftar Isi<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#ringkasan-poin-penting\" >Ringkasan Poin Penting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#mengapa-get-template-directory-uri-selalu-mengarah-ke-parent-theme\" >Mengapa get_template_directory_uri Selalu Mengarah ke Parent Theme?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#solusi-utama-mengarahkan-pemanggilan-file-ke-child-theme\" >Solusi Utama Mengarahkan Pemanggilan File ke Child Theme<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#1-menggunakan-get-stylesheet-directory-uri-untuk-aset-url-publik\" >1. Menggunakan get_stylesheet_directory_uri() untuk Aset URL Publik<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#2-menggunakan-get-stylesheet-directory-untuk-include-file-php-di-server\" >2. Menggunakan get_stylesheet_directory() untuk Include File PHP di Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#3-solusi-modern-menggunakan-get-theme-file-path-dan-get-theme-file-uri\" >3. Solusi Modern Menggunakan get_theme_file_path() dan get_theme_file_uri()<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#solusi-alternatif-dan-perbandingan-fungsi-direktori-tema\" >Solusi Alternatif dan Perbandingan Fungsi Direktori Tema<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#tips-pencegahan-error-saat-mengelola-child-theme\" >Tips Pencegahan Error Saat Mengelola Child Theme<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#pertanyaan-yang-sering-diajukan-faq\" >Pertanyaan yang Sering Diajukan (FAQ)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#mengapa-get-template-directory-uri-tidak-mengarah-ke-child-theme\" >Mengapa get_template_directory_uri() tidak mengarah ke Child Theme?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#apa-perbedaan-antara-get-stylesheet-directory-dan-get-stylesheet-directory-uri\" >Apa perbedaan antara get_stylesheet_directory() dan get_stylesheet_directory_uri()?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#apakah-konstanta-stylesheetpath-dan-templatepath-masih-aman-digunakan\" >Apakah konstanta STYLESHEETPATH dan TEMPLATEPATH masih aman digunakan?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.jnhost.co.id\/blog\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme\/#kesimpulan\" >Kesimpulan<\/a><\/li><\/ul><\/nav><\/div>\n\n<figure class=\"wp-block-image size-large\">\n  <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jnhost.co.id\/blog\/wp-content\/uploads\/2026\/11\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme-hero.jpg\" alt=\"Tampilan halaman Themes di Dashboard WordPress menampilkan Child Theme dan Parent Theme\" class=\"aligncenter\" \/><br \/>\n<\/figure>\n<p>Secara arsitektur, fungsi bawaan <code>get_template_directory_uri()<\/code> dan <code>get_template_directory()<\/code> memang dirancang khusus untuk selalu mengembalikan lokasi direktori Parent Theme. Akibatnya, ketika <strong>Sobat JN<\/strong> menuliskan kode seperti <code>get_template_directory_uri() . '\/myGallery\/gallery_functions_include.php'<\/code> atau menggunakan konstanta lama <code>TEMPLATEPATH<\/code> di dalam Child Theme, sistem akan mencari file tersebut di dalam folder <code>\/wp-content\/themes\/parent-theme\/<\/code> sehingga memicu pesan error <em>file not found<\/em>.<\/p>\n<p>Agar proses pengembangan tema berjalan mulus tanpa hambatan performa, pastikan juga website <strong>Sobat JN<\/strong> berjalan di atas infrastruktur <a href=\"https:\/\/www.jnhost.co.id\/wordpress-hosting-indonesia\/\">WordPress Hosting<\/a> dari JNHOST yang sudah dioptimalkan untuk eksekusi kode tema dan plugin secara cepat. Mari kita bahas langkah perbaikan kode yang tepat agar seluruh pemanggilan file pada Child Theme mengarah ke direktori yang semestinya.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"ringkasan-poin-penting\"><\/span>Ringkasan Poin Penting<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Penyebab Utama:<\/strong> Fungsi <code>get_template_directory_uri()<\/code> dan <code>get_template_directory()<\/code> secara permanen merujuk pada direktori Parent Theme, meskipun Child Theme sedang diaktifkan.<\/li>\n<li><strong>Fungsi URL Child Theme:<\/strong> Gunakan <code>get_stylesheet_directory_uri()<\/code> untuk memanggil URL publik aset di dalam Child Theme seperti file CSS, JavaScript, ikon, atau gambar.<\/li>\n<li><strong>Fungsi Path Server Child Theme:<\/strong> Gunakan <code>get_stylesheet_directory()<\/code> saat menyertakan file <a href=\"https:\/\/www.php.net\/\" target=\"_blank\" rel=\"noopener\">PHP<\/a> menggunakan pernyataan <code>require_once<\/code> atau <code>include<\/code>.<\/li>\n<li><strong>Standar Modern WordPress:<\/strong> Manfaatkan fungsi <code>get_theme_file_uri()<\/code> dan <code>get_theme_file_path()<\/code> untuk mendukung mekanisme pewarisan otomatis (<em>fallback<\/em>) dari Child Theme ke Parent Theme.<\/li>\n<li><strong>Hindari Konstanta Usang:<\/strong> Konstanta <code>TEMPLATEPATH<\/code> dan <code>STYLESHEETPATH<\/code> telah berstatus <em>deprecated<\/em> sejak WordPress 6.4 sehingga wajib diganti dengan fungsi standar.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"mengapa-get-template-directory-uri-selalu-mengarah-ke-parent-theme\"><\/span>Mengapa get_template_directory_uri Selalu Mengarah ke Parent Theme?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Fungsi <code>get_template_directory_uri()<\/code> selalu mengarah ke Parent Theme karena di dalam struktur inti WordPress, istilah <em>template<\/em> merujuk pada paket tema induk yang menyediakan kerangka utama, sedangkan Child Theme diidentifikasi sebagai <em>stylesheet<\/em> aktif. Oleh sebab itu, pemanggilan fungsi yang mengandung kata <code>template<\/code> tidak akan pernah membaca folder Child Theme.<\/p>\n<p>Kebingungan ini kerap terjadi karena penamaan fungsi di masa awal pengembangan WordPress. Banyak pengembang mengira bahwa fungsi <code>get_stylesheet_directory_uri()<\/code> hanya diperuntukkan bagi file <code>style.css<\/code> semata. Padahal, fungsi dengan kata kunci <code>stylesheet<\/code> tersebut merupakan fungsi resmi untuk mengambil lokasi direktori Child Theme secara keseluruhan, baik untuk folder <code>\/js\/<\/code>, <code>\/images\/<\/code>, maupun subfolder modul PHP kustom milik <strong>Sobat JN<\/strong>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"solusi-utama-mengarahkan-pemanggilan-file-ke-child-theme\"><\/span>Solusi Utama Mengarahkan Pemanggilan File ke Child Theme<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Cara paling tepat untuk memperbaiki path yang salah mengarah ke Parent Theme adalah mengganti fungsi keluarga <code>template_directory<\/code> menjadi <code>stylesheet_directory<\/code> atau menggunakan fungsi <code>theme_file<\/code> di dalam file <code>functions.php<\/code> maupun template Child Theme. Berikut adalah langkah penerapan teknisnya sesuai kebutuhan pemanggilan file.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1-menggunakan-get-stylesheet-directory-uri-untuk-aset-url-publik\"><\/span>1. Menggunakan get_stylesheet_directory_uri() untuk Aset URL Publik<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Gunakan fungsi <code>get_stylesheet_directory_uri()<\/code> apabila <strong>Sobat JN<\/strong> ingin menghasilkan alamat URL publik (<code>https:\/\/domain-anda.com\/wp-content\/themes\/child-theme\/...<\/code>) untuk memuat aset statis di sisi browser. Fungsi ini wajib dipakai saat mendaftarkan file CSS, script JavaScript via <code>wp_enqueue_script()<\/code>, atau menampilkan gambar dari folder Child Theme.<\/p>\n<ol>\n<li>Buka pengelola file di <a href=\"https:\/\/cpanel.net\/\" target=\"_blank\" rel=\"noopener\">cPanel<\/a> atau <a href=\"https:\/\/www.directadmin.com\/\" target=\"_blank\" rel=\"noopener\">DirectAdmin<\/a>, ataupun melalui editor kode <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a>.<\/li>\n<li>Arahkan ke direktori <code>wp-content\/themes\/nama-child-theme\/<\/code> dan buka file <code>functions.php<\/code>.<\/li>\n<li>Ganti pemanggilan <code>get_template_directory_uri()<\/code> dengan kode berikut:<\/li>\n<\/ol>\n<pre><code>\/\/ Memuat file CSS dan JS kustom dari dalam folder Child Theme\nfunction jnhost_enqueue_child_assets() {\n    wp_enqueue_style(\n        'child-custom-gallery-css',\n        get_stylesheet_directory_uri() . '\/myGallery\/gallery-style.css',\n        array(),\n        '1.0.0',\n        'all'\n    );\n\n    wp_enqueue_script(\n        'child-custom-gallery-js',\n        get_stylesheet_directory_uri() . '\/myGallery\/gallery-script.js',\n        array( 'jquery' ),\n        '1.0.0',\n        true\n    );\n}\nadd_action( 'wp_enqueue_scripts', 'jnhost_enqueue_child_assets' );<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2-menggunakan-get-stylesheet-directory-untuk-include-file-php-di-server\"><\/span>2. Menggunakan get_stylesheet_directory() untuk Include File PHP di Server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Gunakan fungsi <code>get_stylesheet_directory()<\/code> (tanpa akhiran <code>_uri<\/code>) ketika <strong>Sobat JN<\/strong> perlu menyertakan file logika PHP menggunakan <code>include<\/code> atau <code>require_once<\/code>. Pernyataan <code>include<\/code> di PHP membutuhkan jalur absolut sistem file di server (seperti <code>\/home\/user\/public_html\/wp-content\/themes\/child-theme\/...<\/code>), bukan URL HTTP.<\/p>\n<figure class=\"wp-block-image size-large\">\n  <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jnhost.co.id\/blog\/wp-content\/uploads\/2026\/11\/solusi-jitu-mengatasi-get-template-directory-uri-ke-parent-theme-solusi.jpg\" alt=\"Tampilan kode get_stylesheet_directory_uri dan get_stylesheet_directory pada file functions.php Child Theme\" class=\"aligncenter\" \/><br \/>\n<\/figure>\n<p>Jika sebelumnya <strong>Sobat JN<\/strong> menulis <code>include (TEMPLATEPATH . '\/myGallery\/gallery_functions_include.php');<\/code>, segera perbarui baris tersebut menjadi seperti di bawah ini:<\/p>\n<pre><code>\/\/ Menyertakan file PHP dari dalam folder Child Theme secara aman\nrequire_once get_stylesheet_directory() . '\/myGallery\/gallery_functions_include.php';<\/code><\/pre>\n<p>Penggunaan <code>get_stylesheet_directory()<\/code> memastikan script langsung mencari file di dalam folder Child Theme. Selain itu, bila situs <strong>Sobat JN<\/strong> suatu saat tidak menggunakan Child Theme, fungsi ini otomatis tetap mengarah ke tema utama yang aktif tanpa menimbulkan error.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3-solusi-modern-menggunakan-get-theme-file-path-dan-get-theme-file-uri\"><\/span>3. Solusi Modern: Menggunakan get_theme_file_path() dan get_theme_file_uri()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Sejak WordPress versi 4.7 ke atas, cara paling direkomendasikan untuk memanggil file di dalam tema adalah menggunakan fungsi <code>get_theme_file_path()<\/code> untuk path server dan <code>get_theme_file_uri()<\/code> untuk URL publik. Kedua fungsi ini secara cerdas memeriksa ketersediaan file di dalam Child Theme terlebih dahulu, lalu otomatis beralih (<em>fallback<\/em>) ke Parent Theme jika file tersebut belum ada di Child Theme.<\/p>\n<pre><code>\/\/ 1. Menyertakan file PHP (otomatis cek Child Theme dulu, lalu Parent Theme)\nrequire_once get_theme_file_path( '\/myGallery\/gallery_functions_include.php' );\n\n\/\/ 2. Memanggil URL aset dari Child Theme dengan fallback otomatis\nwp_enqueue_style(\n    'custom-style',\n    get_theme_file_uri( '\/style\/some.css' ),\n    array(),\n    '1.0.0',\n    'all'\n);<\/code><\/pre>\n<p>Pendekatan ini sangat membantu <strong>Sobat JN<\/strong> yang mengelola banyak situs klien di layanan <a href=\"https:\/\/www.jnhost.co.id\/cloud-hosting-indonesia-terbaik\/\">Cloud Hosting<\/a> karena struktur kode menjadi jauh lebih rapi, modular, dan tahan terhadap pembaruan versi tema induk.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"solusi-alternatif-dan-perbandingan-fungsi-direktori-tema\"><\/span>Solusi Alternatif dan Perbandingan Fungsi Direktori Tema<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Sebagai metode alternatif apabila <strong>Sobat JN<\/strong> memanggil file PHP yang letaknya relatif terhadap file yang sedang dieksekusi di dalam Child Theme, konstanta bawaan PHP <code>__DIR__<\/code> juga dapat digunakan. Namun, untuk menjaga konsistensi standar pengembangan tema, pemakaian fungsi native WordPress tetap menjadi pilihan terbaik.<\/p>\n<pre><code>\/\/ Alternatif menggunakan konstanta bawaan PHP __DIR__\nrequire_once __DIR__ . '\/myGallery\/gallery_functions_include.php';<\/code><\/pre>\n<p>Agar <strong>Sobat JN<\/strong> tidak salah memilih fungsi saat memodifikasi tema di paket <a href=\"https:\/\/www.jnhost.co.id\/unlimited-hosting-indonesia\/\">Unlimited Hosting<\/a>, simak tabel perbandingan fungsi lokasi direktori tema berikut ini:<\/p>\n<table>\n<thead>\n<tr>\n<th>Nama Fungsi \/ Konstanta<\/th>\n<th>Target Direktori<\/th>\n<th>Output yang Dihasilkan<\/th>\n<th>Status dan Rekomendasi<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>get_template_directory_uri()<\/code><\/td>\n<td>Parent Theme<\/td>\n<td>URL Publik (<code>https:\/\/...<\/code>)<\/td>\n<td>Aktif (Khusus aset Parent Theme)<\/td>\n<\/tr>\n<tr>\n<td><code>get_template_directory()<\/code><\/td>\n<td>Parent Theme<\/td>\n<td>Path Server (<code>\/home\/...<\/code>)<\/td>\n<td>Aktif (Khusus file PHP Parent Theme)<\/td>\n<\/tr>\n<tr>\n<td><code>get_stylesheet_directory_uri()<\/code><\/td>\n<td>Child Theme<\/td>\n<td>URL Publik (<code>https:\/\/...<\/code>)<\/td>\n<td><strong>Direkomendasikan<\/strong> (Aset Child Theme)<\/td>\n<\/tr>\n<tr>\n<td><code>get_stylesheet_directory()<\/code><\/td>\n<td>Child Theme<\/td>\n<td>Path Server (<code>\/home\/...<\/code>)<\/td>\n<td><strong>Direkomendasikan<\/strong> (Include PHP Child Theme)<\/td>\n<\/tr>\n<tr>\n<td><code>get_theme_file_uri( $file )<\/code><\/td>\n<td>Child Theme (Fallback Parent)<\/td>\n<td>URL Publik (<code>https:\/\/...<\/code>)<\/td>\n<td><strong>Standar Terbaik Modern<\/strong><\/td>\n<\/tr>\n<tr>\n<td><code>get_theme_file_path( $file )<\/code><\/td>\n<td>Child Theme (Fallback Parent)<\/td>\n<td>Path Server (<code>\/home\/...<\/code>)<\/td>\n<td><strong>Standar Terbaik Modern<\/strong><\/td>\n<\/tr>\n<tr>\n<td><code>TEMPLATEPATH<\/code> \/ <code>STYLESHEETPATH<\/code><\/td>\n<td>Parent \/ Child Theme<\/td>\n<td>Path Server (<code>\/home\/...<\/code>)<\/td>\n<td><strong>Deprecated (Hindari Penggunaan)<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span class=\"ez-toc-section\" id=\"tips-pencegahan-error-saat-mengelola-child-theme\"><\/span>Tips Pencegahan Error Saat Mengelola Child Theme<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>Pisahkan Folder Kustomisasi dengan Rapi:<\/strong> Simpan seluruh file tambahan seperti <code>\/includes\/<\/code>, <code>\/images\/<\/code>, <code>\/js\/<\/code>, dan <code>\/style\/<\/code> di dalam direktori Child Theme agar tidak terhapus ketika Parent Theme diperbarui.<\/li>\n<li><strong>Jangan Gunakan URL pada include PHP:<\/strong> Hindari memasukkan <code>get_stylesheet_directory_uri()<\/code> ke dalam fungsi <code>include()<\/code> atau <code>require()<\/code> karena sebagian besar server produksi menonaktifkan fitur <code>allow_url_include<\/code> demi keamanan.<\/li>\n<li><strong>Hapus Pemakaian TEMPLATEPATH dan STYLESHEETPATH:<\/strong> Lakukan audit pada file tema lama dan ganti kedua konstanta tersebut dengan <code>get_stylesheet_directory()<\/code> atau <code>get_theme_file_path()<\/code> agar bebas dari peringatan <em>PHP Deprecated Notice<\/em>.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"pertanyaan-yang-sering-diajukan-faq\"><\/span>Pertanyaan yang Sering Diajukan (FAQ)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"mengapa-get-template-directory-uri-tidak-mengarah-ke-child-theme\"><\/span>Mengapa get_template_directory_uri() tidak mengarah ke Child Theme?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Fungsi <code>get_template_directory_uri()<\/code> dirancang oleh sistem inti WordPress untuk selalu mengambil URL dari Parent Theme (tema induk). Untuk mengambil URL dari Child Theme yang sedang aktif, gunakan fungsi <code>get_stylesheet_directory_uri()<\/code> atau <code>get_theme_file_uri()<\/code>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"apa-perbedaan-antara-get-stylesheet-directory-dan-get-stylesheet-directory-uri\"><\/span>Apa perbedaan antara get_stylesheet_directory() dan get_stylesheet_directory_uri()?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Fungsi <code>get_stylesheet_directory()<\/code> mengembalikan jalur direktori absolut di server (contoh: <code>\/home\/user\/public_html\/wp-content\/themes\/child-theme<\/code>) yang digunakan untuk perintah <code>include<\/code> atau <code>require_once<\/code> di PHP. Sebaliknya, <code>get_stylesheet_directory_uri()<\/code> mengembalikan alamat URL publik (contoh: <code>https:\/\/domain.com\/wp-content\/themes\/child-theme<\/code>) untuk memuat file CSS, JS, dan gambar di browser.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"apakah-konstanta-stylesheetpath-dan-templatepath-masih-aman-digunakan\"><\/span>Apakah konstanta STYLESHEETPATH dan TEMPLATEPATH masih aman digunakan?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Tidak disarankan. Konstanta <code>STYLESHEETPATH<\/code> dan <code>TEMPLATEPATH<\/code> telah resmi dinyatakan usang (<em>deprecated<\/em>) sejak WordPress versi 6.4. Sebagai gantinya, gunakan fungsi <code>get_stylesheet_directory()<\/code>, <code>get_template_directory()<\/code>, atau <code>get_theme_file_path()<\/code>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"kesimpulan\"><\/span>Kesimpulan<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Mengatasi masalah <code>get_template_directory_uri<\/code> yang terus mengarah ke Parent Theme sebenarnya sangat praktis begitu <strong>Sobat JN<\/strong> memahami perbedaan peran antara fungsi <code>template<\/code> dan <code>stylesheet<\/code> di WordPress. Cukup ganti pemanggilan URL aset menggunakan <code>get_stylesheet_directory_uri()<\/code> dan pemanggilan file PHP server menggunakan <code>get_stylesheet_directory()<\/code> atau <code>get_theme_file_path()<\/code>, maka seluruh modul kustom di Child Theme akan langsung terbaca dengan akurat.<\/p>\n<p>Apabila <strong>Sobat JN<\/strong> membutuhkan lingkungan server yang stabil, responsif, dan dilengkapi dukungan teknis 24\/7 untuk mengelola berbagai proyek website WordPress, layanan hosting dari <strong>JNHOST<\/strong> siap menjadi fondasi terbaik bagi performa situs <strong>Sobat JN<\/strong>.<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Mengapa get_template_directory_uri() tidak mengarah ke Child Theme?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Fungsi get_template_directory_uri() dirancang oleh sistem inti WordPress untuk selalu mengambil URL dari Parent Theme (tema induk). Untuk mengambil URL dari Child Theme yang sedang aktif, gunakan fungsi get_stylesheet_directory_uri() atau get_theme_file_uri().\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Apa perbedaan antara get_stylesheet_directory() dan get_stylesheet_directory_uri()?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Fungsi get_stylesheet_directory() mengembalikan jalur direktori absolut di server (contoh: \/home\/user\/public_html\/wp-content\/themes\/child-theme) yang digunakan untuk perintah include atau require_once di PHP. Sebaliknya, get_stylesheet_directory_uri() mengembalikan alamat URL publik (contoh: https:\/\/domain.com\/wp-content\/themes\/child-theme) untuk memuat file CSS, JS, dan gambar di browser.\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Apakah konstanta STYLESHEETPATH dan TEMPLATEPATH masih aman digunakan?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Tidak disarankan. Konstanta STYLESHEETPATH dan TEMPLATEPATH telah resmi dinyatakan usang (deprecated) sejak WordPress versi 6.4. Sebagai gantinya, gunakan fungsi get_stylesheet_directory(), get_template_directory(), atau get_theme_file_path().\"\n      }\n    }\n  ]\n}\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Temukan solusi jitu mengatasi get_template_directory_uri mengarah ke parent theme di WordPress agar aset dan file Child Theme termuat sempurna.<\/p>\n","protected":false},"author":1,"featured_media":11974,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","rank_math_title":"Solusi Jitu Mengatasi get_template_directory_uri ke Parent Theme","rank_math_description":"Temukan solusi jitu mengatasi get_template_directory_uri mengarah ke parent theme di WordPress agar aset dan file Child Theme termuat sempurna.","rank_math_canonical_url":"","rank_math_focus_keyword":"get_template_directory_uri mengarah ke parent theme"},"categories":[3,369],"tags":[843,906,844,54],"class_list":["post-11976","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial-wordpress","category-wordpress-themes","tag-child-theme","tag-functions-php","tag-parent-theme","tag-theme-customization"],"_links":{"self":[{"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/posts\/11976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/comments?post=11976"}],"version-history":[{"count":0,"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/posts\/11976\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/media\/11974"}],"wp:attachment":[{"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/media?parent=11976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/categories?post=11976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jnhost.co.id\/blog\/wp-json\/wp\/v2\/tags?post=11976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}