Npcink Blog
切换菜单

Wordpress 的 functions.php 引用其他 php 文件-Wordpress 主题开发

让 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