日期:2014-09-14 阅读:4260
dmandwp系统 - wordpress系统和DM系统区块建站>>
文档:
https://developer.wordpress.org/reference/functions/wp_enqueue_style
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
https://developer.wordpress.org/reference/functions/wp_enqueue_script
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
比如加入bootstrap:
在twentyseventeen的function.php里的function twentyseventeen_scripts()里加以下代码:
---------------------
具体请看视频教程,
--------------------------------
老的办法:
先在当前主题下的function.php最前加:
define('MBDIR',get_template_directory().'/' ); //这个可以用于require
//这个现在不用了,可以用 get_template_part
define('MBURI',get_template_directory_uri().'/' ); //这个可以用来引用css,js
define('DEFIMG',get_site_url().'/default.jpg'); //这是一张默认图片
define('DEFIMGDIV','<img src="'.DEFIMG.'" alt="" />');
然后再
function twentythirteen_scripts_styles() {。。。里加css或js
或在header.php里加以下代码:
<?php wp_head(); ?>
<link rel='stylesheet' href='<?php echo MBURI?>css/tv-wp.css' type='text/css' media='all' />
<script type='text/javascript' src='<?php echo MBURI?>js/tv-wp.js'></script>
------
头部插入搜索表单的api:
<?php get_search_form(); ?>
调用头部的文件是在 wp-includes 下的 general-template.php
比如 get_header(); ---调用 header.php
get_header('img'); ---调用 header-img.php
----------------
来自: http://codex.wordpress.org/Function_Reference/home_url
WordPress Directories:
home_url() Home URL http://www.example.com
site_url() Site directory URL http://www.example.com or http://www.example.com/wordpress
admin_url() Admin directory URL http://www.example.com/wp-admin
includes_url() Includes directory URL http://www.example.com/wp-includes
content_url() Content directory URL http://www.example.com/wp-content
plugins_url() Plugins directory URL http://www.example.com/wp-content/plugins
theme_url() Themes directory URL (#18302) http://www.example.com/wp-content/themes
wp_upload_dir() Upload directory URL (returns an array) http://www.example.com/wp-content/uploads