讓functions.php文件整潔一點。
functions.php里面放了很多我們常用的函數,我們來整理一下。
讓他好看一點。
引用主題根目錄文件:
//測試
require_once('test.php');
引用主題根目錄的其他文件:
//設置面板
require get_template_directory() . '/inc/test.php';
下面的函數是在主題的自定義面板添加一個文本選項框:(放到functions.php文件)
//自定義地址
function do_customize_register( $wp_customize ) {//do
$wp_customize->add_section('header_db',array(//db
'title' => '地址',
'priority' => 50
) );
$wp_customize->add_setting( 'header_db', array(//db
'default' => '',
"transport" => "postMessage",
'type' => 'option'
) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'header_db', array(//db
'label' => '首頁的地址坐標',
'section' => 'header_db'//db
) ) );
}
add_action( 'customize_register', 'do_customize_register' );//do