Bypass Template Path dan Stylesheet Path

10 Feb. 201134 comments

Melanjutkan postingan sebelumnya tentang Optimasi File wp-config.php, kali akan saya sampaikan tips dan trik menghack jalur template dan stylesheet  dengan cara mem-bypass Template Path dan Stylesheet Path dari theme aktif yang kita gunakan.

Masih bingung dengan keterangan di atas? Sekarang coba perhatikan script atau tag berikut ini :

<?php get_bloginfo('stylesheet_directory'); ?> — Returns the URL of the stylesheet directory of the active theme
<?php get_bloginfo('template_directory'); ?> — Returns the URL of the active theme’s directory
<?php bloginfo('stylesheet_directory'); ?> — Displays the URL of the stylesheet directory of the active theme
<?php bloginfo('template_directory'); ?> — Displays the URL of the active theme’s directory
<?php get_stylesheet_directory(); ?> — Returns the stylesheet directory path for the current theme
<?php get_template_directory() ?> — Returns the absolute path for the template directory of the current theme

Script atau tag tersebut banyak kita jumpai di beberapa file yang ada di folder theme yang digunakan. Tag ini berfungsi dengan asumsi struktur direktori standar untuk instalasi WordPress seperti ini : ../wp-content/themes/).

Dengan susunan tag seperti di atas maka setiap blog diakses akan ada permintaan query ke database terlebih dahulu untuk jalur template dan stylesheet dari theme yang aktif.

Semenjak WordPress versi 2.2 kita bisa mengesampingkan permintaan queri ke database dengan cara mem-bypass Template Path dan Stylesheet Path dari theme yang digunakan (theme aktif).  Caranya tambahkan script atau tag berikut ini  ke dalam file wp-config.php :

define('TEMPLATEPATH', '/absolute/path/to/wp-content/themes/inove');
define('STYLESHEETPATH', '/absolute/path/to/wp-content/themes/inove');

Ganti yang saya beri warna merah (inove) dengan nama (folder ) theme yang anda gunakan.

Letakkan kode tersebut sebelum kode berikut ini :

/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');

Catatan : khusus untuk define('STYLESHEETPATH', '/absolute/path/to/wp-content/themes/namafoldertheme'); bisa digunakan jika url Stylesheet Path yang ada di file header.php masih asli alias belum dicustom seperti yang pernah saya bahas di sini : How To Minimize SQL Queries dan di sini : Optimasi File CSS.

Artikel Yang Mungkin Berkaitan :

  1. Custom CSS Per Post
  2. 80 Inspirasi, Design Footer Nan Cantik Dan Unik
  3. Membuat Background Pattern Dengan CSS3 Repeat Linear Gradient
  4. Cara Mengganti Font Dalam Postingan
  5. Tips dan Tricks CSS (Cascading Style Sheets)
  6. Border Style, Border Width, Border Color
  7. Yesterday, The Beatles
  8. CSS Image Sprites Generator
  9. Membuat Text Gradient Dengan CSS
  10. Modifikasi Tampilan Halaman Daftar Isi
  1. 21-4-2011 at 23:15 | #1

    wah sulit y.. ga mudeng euyy hehee

    Reply

  2. 18-5-2011 at 19:11 | #2

    Bagusan mana ama cara stylepath manual ?

    Reply

  3. 21-8-2011 at 07:59 | #3

    masih bingung gan, ?? baru belajar bahasa pemrograman php =))

    Reply

  4. gunawan
    7-9-2011 at 12:34 | #4

    msh blm paham dg tulisan di atas. bos mau tanya.
    Kalo css kn bs digabungkn dg html, script css ditaruh diantara dan .
    Nah bagaimana cara menggabungkan php mjd 1 dg html?
    Atau adakah tulisan dr jenengan yg menjelaskan ttg html dan php?
    Trmksh.

    Reply

  5. 15-10-2011 at 07:46 | #5

    salam sukses mas bro alwi,… ane gunakan trik ini diwebsite toko ane, alhamdulillah beres,.. cepet banget loadingnya,.. tapi kok nama website www. ndak bisa di setting ya,.. he3,.. bagimana caranya mas bro..

    Reply

  6. 20-3-2012 at 23:02 | #6

    Mas saya coba tutor diatas kog malah fatal eror kayak gini ya
    “Warning : copy(/absolute/path/to/wp-content/themes/NewsSlide/index.php) [ function.copy ]: failed to open stream: No such file or directory in /home/u976496576/public_html/wp-content/plugins/easy-content-types/includes/register-post-types.php on line 68
    Anda tidak memiliki cukup izin untuk mengakses halaman ini.”

    Reply

  7. 19-4-2012 at 14:37 | #7

    Bingung nih bro, padahal menurut saya sangat penting ini, bisa mangkas query ke server = loading page ringan.

    :D

    Reply

  8. 30-4-2012 at 13:56 | #8

    lam kenal, mo tnya, klo ky gni sama aja g?
    define(‘TEMPLATEPATH’, ‘/home/***/public_html/wp-content/themes/namafoldertheme’);
    define(‘STYLESHEETPATH’, ‘/home/***/public_html/wp-content/themes/namafoldertheme’);

    soalnya klo pke /absolute/path/to lgsng blank web ny :(

    Reply

Comment pages
1 22238
3+8=? (Wajib diisi)