WordPress-2次开发常用函数
全函数列表请参见这里:《WordPress模板标签Template_Tags》。
这里只列出最常用的几个。先是重要的bloginfo(),不直接echo数值的函数为get_bloginfo();恩,不少函数都是按照这个规则写的,PS:并不是全部!echo出函数值的函数为xxx()的话,那么不echo出结果值的的函数为get_xxx()。
该函数范围的是WordPress的配置参数,主要参数和值举例如下,常用的黑体标出:
admin_email = admin@example
atom_url = http://example/home/feed/atom
charset = UTF-8
comments_atom_url = http://example/home/comments/feed/atom
comments_rss2_url = http://example/home/comments/feed
description = Just another WordPress blog
home = http://example/home这个是网站首页地址
html_type = text/html
language = en-US
name = Testpilot网站名称
pingback_url = http://example/home/wp/xmlrpc.php
rdf_url = http://example/home/feed/rdf
rss2_url = http://example/home/feed
rss_url = http://example/home/feed/rss
siteurl = http://example/home也是网站地址
stylesheet_directory = http://example/home/wp/wp-content/themes/largo
stylesheet_url = http://example/home/wp/wp-content/themes/largo/style.css主题文件夹下的style.css地址
template_directory = http://example/home/wp/wp-content/themes/largo主题包地址
template_url = http://example/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://example/home
version = 2.7
wpurl = http://example/home/wp
举例,bloginfo("wpurl ")会输出“http://example/home/wp”。
WordPress-Theme的制作
以下内容建立在有部分HTML基础下,如果有疑问可以Twitter我,EMAIL我,MSN我,留言我,电话我,etc,但是不要QQ我~
WP的主题所在文件夹为XXX\wp-content\themes\,里边每个包都是目录(如果正常的话)。
先来讲下主题的组成,可以先参考这个文章《WordPress -Template System模板系统》。
从该文章中我们可以发现,最最最简单的WP皮肤只需要一个文件,index.php,出于维护和多方合作开发以及修改的简便性来说,个人觉得一个主题至少应该分成以下几个部分:
header.php,里边放HTML的头部,一般是包含文档声明到body开始处,有时候也会包含菜单部分。
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>< ?php bloginfo('name'); ?> < ?php if ( is_single() ) { ?> Blog Archive < ?php } ?> < ?php wp_title(); ?></title>
..................
<body>