wordpress引入php文件,Wordpress引入其他程序文件方法

方法1-推荐

各wordpress官方主题使用

require get_template_directory() . '/inc/template-tags.php';

/**

* Twenty Nineteen only works in WordPress 4.7 or later.

*/

if ( version_compare( $GLOBALS['wp_version'], '4.7', '

require get_template_directory() . '/inc/back-compat.php';

return;

方法2

通过

例如:understrap等主题使用

$understrap_includes = array(

'/theme-settings.php', // Initialize theme default settings.

'/setup.php', // Theme setup and custom theme supports.

'/widgets.php', // Register widget area.

'/enqueue.php', // Enqueue scripts and styles.

'/template-tags.php', // Custom template tags for this theme.

'/pagination.php', // Custom pagination for this theme.

'/hooks.php', // Custom hooks.

'/extras.php', // Custom functions that act independently of the theme templates.

'/customizer.php', // Customizer additions.

'/custom-comments.php', // Custom Comments file.

'/jetpack.php', // Load Jetpack compatibility file.

'/class-wp-bootstrap-navwalker.php', // Load custom WordPress nav walker.

'/woocommerce.php', // Load WooCommerce functions.

'/editor.php', // Load Editor functions.

'/deprecated.php', // Load deprecated functions.

);

foreach ( $understrap_includes as $file ) {

$filepath = locate_template( 'inc' . $file );

if ( ! $filepath ) {

trigger_error( sprintf( 'Error locating /inc%s for inclusion', $file ), E_USER_ERROR );

}

require_once $filepath;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值