烈火建站学院(LieHuo.Net)讯 在以前的文章中我们介绍了的,这篇教程介绍一下主题index.php代码,它是生成的是网站首页显示的内容,还是以默认模板default为例。下面是index.php的完整代码:
以下为引用的内容:
id="post-">
|
先说下三个函数get_header(); get_sidebar(); get_footer();分别输出各自的模板代码如header.php、sidebar.php、footer.php;相应的模板代码生成后加入相应位置。
第5行的if (have_posts()) : 为判断是否含有日志;
第7行的 while (have_posts()) : 为当有日志时,进行循环操作;the_post(); 为对单个循环中的一篇日志进行操作。
第9行:post_class();输出个性化的日志class——官方参考例如置顶文章回输出不同的class,可以加入参数自定义生成的类名如:post_class(’myclass’);;the_ID();生成日志id数字号。
第10行:the_permalink()为每篇日志对应内容页的链接,the_title();为日志标题;
第11行:the_time(__(’F jS, Y’, ‘kubrick’)为日志发布时间;
第14行:the_content(__(’Read the rest of this entry »’, ‘kubrick’));为日志内容;
第17行:the_tags(__(’Tags:’, ‘kubrick’) . ‘ ‘, ‘, ‘, ‘
’); 为日志所在标签;printf(__(’Posted in %s’, ‘kubrick’), get_the_category_list(’, ‘));为日志所在分类;
第20行: endwhile; 结束循环;
第23行: next_posts_link(__(’« Older Entries’, ‘kubrick’))上一篇日志链接;
第24行: previous_posts_link(__(’Newer Entries »’, ‘kubrick’)) ?>下一篇日志链接;
第27行: else : 为没有日志时候的情况,
第29行:php _e(’Not Found’, ‘kubrick’);为没有发现日志
第30行:php _e(’Sorry, but you are looking for something that isn’t here.’, ‘kubrick’);为相关提示;
第31行:include (TEMPLATEPATH . “/searchform.php”);插入搜索表单模板;
第33行:endif;结束判断。