讓functions.php文件整潔一點(diǎn)。
functions.php里面放了很多我們常用的函數(shù),我們來整理一下。
讓他好看一點(diǎn)。
引用主題根目錄文件:
//測試
require_once('test.php');
引用主題根目錄的其他文件:
//設(shè)置面板
require get_template_directory() . '/inc/test.php';
下面的函數(shù)是在主題的自定義面板添加一個(gè)文本選項(xiàng)框:(放到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' => '首頁的地址坐標(biāo)',
'section' => 'header_db'//db
) ) );
}
add_action( 'customize_register', 'do_customize_register' );//do