Wordpress 一些函数列表
收集下WP的一些函数列表方便活着在制作主题的时候使用。另外,Inove主题是一个可以参考的主题,能够找到许多的有用函数,功能强大能够帮助自己制作一款同样强大的主题。
bloginfo(),调用博客信息,函数参数有’name’(博客标题)、_e(),输出文字到文档,例如_e(?你好?>使用效果为输出“你好”二字,此函数不是必须的,只是在用来创建可以翻译的主题时使用
get_header() Wordpress主题系统用来包含header.php文件的函数
include (TEMPLATEPATH.”header.php”)用来包含文件
get_sidebar(),用于显示 wordpress 边栏
get_footer(),用于显示页脚,即footer.php文件
comments_template(),调用评论模板,需要创建comments.php文件
have_posts()判断你的博客是否有日志,举例:<?php if(have_posts()) : ?>
the_post()输出日志内容,the_title()输出日志标题,the_permalink()日志链接,the_content()输出博客内容。
使用方法:<?php while(have_posts()) : the_post(); ?><a href=?<?php the_permalink(); ?>?><?php the_title(); ?></a><?php endwhile; ?>
the_category(),当前日志所在的所有类别。例如<?php the_category(?, ?) ?>,其中“,”用来区别分类别名。显示结果如此:Name of category 1,Name of category 2
the_author()用来输出当前日志作者的名字
comments_popup_link()调用一个弹出的留言窗口。(此功能必须在后台开启弹出留言的功能),如果没有激活,
comments_popup_link() 则只是简单的显示留言列表。例如<?php comments_popup_link(?No Comments »?, ?1 Comment»?, ?% Comments »?); ?>
No Comments »是在没有留言的时候显示的。1 Comment » 是用于当你刚好有1条留言时候。% Comments &187; 是用于当你有多于一条留言的时候。比如:8 Comments 。百分号 % 用来显示数字。» 是用来显示一个双层箭头 ?。单篇日志查看模式下留言链接函数是不起作用的
edit_post_link(),显示日志编辑链接.这个只有当你以管理身份登录的时候(编辑者,Editor登录也可以)才可见.edit_post_link() 有三个参数。第一个是用来确定哪个词你将用在编辑链接的链接标题。第二个参数是用来显示在链接后面的字符。第三个参数是用于显示在编辑链接后面的字符。如:<?php edit_post_link(“Edit”, ” | “, ?); ?>
the_ID()日志ID
wp_list_cats()调用wordpress分类链接列表,有三个参数.如<?php wp_list_cats(“sort_column=name&optioncount=1&hierarchical=0″); ?>,其中sort_column=name表示把分类按字符顺序排列,optioncount=1表示每个分类下面的日志数,hierarchial=0表示不把子分类放到子列表元素中.
get_calendar(),输出日历
wp_register(),注册
wp_loginout()登陆或退出
wp_meta(),元数据
previous_post_link(),next_post_link()分别显示上一篇与下一篇的链接.如<?php previous_post_link(’«%link‘) ?>
page.php 模板文件定制函数
link_pages()显示子页面的链接,例如<?php link_pages(?<p><strong>Pages:</strong> ?, ?</p>?, ?number?); ?>
在 page.php 中,在 <?php the_content(); ?> 输入以下代码:
<?php link_pages(?<p><strong>Pages:</strong> ?, ?</p>?, ?number?); ?>
wp_list_pages(),显示页面列表,使用depth参数限制列表的层数.
get_links_list()显示友情链接
wp_get_archives(),用于显示文章归档列表,例如:wp_get_archives(“type=monthly”)
posts_nav_link()调用博客分页,示例:<?php posts_nav_link(“in between”,”before”,”after”); ?>
你不会吧,要是有时间弄个大全,我以后就来这参考得了
@wulinfo:呃,这个值得考虑呢,做个系列赚点长期流量。好主意……哈哈