19.8.16

On 12:50 PM by GreenSkyIT     No comments
Như các bạn đã biết cấu trúc một giao điện website Wordpress gồm 4 phần "Header, Conten, Siderbar, Footer".

....
Để có thể lấy đường dẫn của file style để thiết kế giao điện web thì bạn dùng Funtion

<?php bloginfo('stylesheet_url'); ?>

Với câu lệnh trên bạn sẽ lấy ra file style.css với cấu trúc thư mục như hình dưới. Ở đây với file style.css thì nó sẽ nằm ở thư mục gốc của folder thêm.

Trong trường hợp bạn tự tạo một file style hay bạn sử dụn thư viện Bootrap  với cấu trúc như ở dưới thì điều này cũng khá đơn giản.

bootstrap/
├── css/
│   ├── bootstrap.css
│   ├── bootstrap.min.css
│   ├── bootstrap-theme.css
│   └── bootstrap-theme.min.css
├── js/
│   ├── bootstrap.js
│   └── bootstrap.min.js
└── fonts/
    ├── glyphicons-halflings-regular.eot
    ├── glyphicons-halflings-regular.svg
    ├── glyphicons-halflings-regular.ttf
    └── glyphicons-halflings-regular.woff
 
 Funtion để lấy link của file như sau :

<?php echo get_stylesheet_directory_uri() ?>/bootstrap/css/bootstrap-theme.css

Vậy câu lệnh để chèn các file style vào file Header như sau :

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
 <!--Lấy thư viện bootrap-->
 <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri() ?>/bootstrap/css/bootstrap.min.css">
 <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri() ?>/bootstrap/css/bootstrap-theme.min.css">
Xem thêm phần 2 :


0 comments :

Post a Comment