开源夏令营(8)

来源:互联网 发布:windows系统常用命令 编辑:程序博客网 时间:2024/05/22 10:08

在wordpress中,所谓模板标签一般是指一篇文章的字段,比如一篇文章的标题,内容,作者,发布日期,评论数等等.
输出模板标签一般有两种方式:the_yourtag() 和get_the_yourtag();
the_yourtag()会直接把标签内容打印到html上面;
get_the_yourtag()会把标签内容保存到一个变量中,以供稍后的使用;
通常来说,the_yourtag()==echo get_the_yourtag();

例如拿标题来举例,以下两段代码是等效的:
(代码一)

<?php the_title(); ?>

(代码二)

<?php echo get_the_title();?>###注意the_permalink()对应的是get_permalink(),没有 'the';

模板标签大全:http://codex.wordpress.org/Template_Tags
常用的模板标签:

<?php the_content(); ?> 日志内容  <?php the_title(); ?> 显示一篇日志或页面的标题  <?php the_permalink() ?> 显示一篇日志或页面的永久链接/URL地址  <?php the_category(',') ?> 显示一篇日志或页面的所属分类  <?php the_author(); ?> 显示一篇日志或页面的作者  <?php the_ID(); ?> 显示一篇日志或页面的ID  <?php edit_post_link(); ?> 显示一篇日志或页面的编辑链接  <?php next_post_link('%link') ?> 下一篇日志的URL地址  <?php previous_post_link('%link') ?> 上一篇日志的URL地址  
0 0
原创粉丝点击