Posts Subscribe to This BlogComments

Follow Us

Bypass Template Path dan Stylesheet Path

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.

Related Post



1 komentar:

  • Posting Komentar

    Ads Header

    Blogger Themes

    free counters

    Blogger Tricks

    CREATED BY : IMAM MUNANDAR
     

    Followers