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
软件

ImageOptim - 使图像加载更快

2019-11-27 19:56:33

插件

百度熊掌号

2018-7-13 15:14:30

⚠️
Npcink上的部份代码及教程来源于互联网,仅供网友学习交流,若您喜欢本文可附上原文链接随意转载。
无意侵害您的权益,请发送邮件至 1355471563#qq.com 或点击右侧 私信:Muze 反馈,我们将尽快处理。
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索