- 文件
header.php
footer.php
front-page.php //默认显示的页面
404.php
search.php
archive.php
index.php //入口文件
page.php
single.php
style.css //样式文件 - 方法
get_header(); 获取header.php文件
get_footer(); 获取footer.php文件
wp_head(); 获取编辑头
wp_footer(); 获取默认的footer
the_title() 获取页面title - functions.php引入css和js文件
// 引入CSS文件
function load_css()
{
wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), false, 'all');
wp_enqueue_style('bootstrap');
}
add_action('wp_enqueue_scripts', 'load_css');// 引入JS文件
function load_js()
{
wp_enqueue_script('jquery');wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), false, true);
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts', 'load_js'); - 创建一个模板,在主题文件夹下,随意创建一个php文件,然后加入以下注释
<?php
/*
Template Name: Contact Us
*/
?>
就可以在页面右侧的template中找到这个模板。
- 默认引入header是get_header(); 如果需要不同的header,创建一个header_xxx.php文件,然后使用get_header('xxx')就可以让页面使用不同的header。同样适用于get_footer()。
最新回复