wordpress通用主题下index.php文件中常用函数解释
下面通一个最简单的代码来说明:
<body> <div id="header"> <h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1> <?php bloginfo('description'); ?> <!--上面三个函数分别是取出BLOG的链接地址,名称,描述,要了解更多bloginfo()的参数,请看本站的“WordPress的bloginfo(), get_bloginfo()函数详解”--> </div> <div id="container"> <?php if(have_posts()): ?><?php while(have_posts()): the_post(); ?> <!--have_posts()判断是否存在日志,the_post()用来显示具体日志的函数,只有在存在日志的前提下才会执行--> <div class="post"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <!--the_permalink()为具体一篇日志的链接地址,the_title()为日志的标题--> <div class="entry"> <?php the_content(); ?> <!--the_content()为日志的内容--> <p class="postmetadata"> <?php _e("Filed under:"); ?> <?php the_category(',') ?> — <!--the_category()为日志分类,参数为多个分类的分隔符号--> <?php the_tags(__('Tags: '), ', ', ' — '); ?> <!--the_tags()为日志的标签--> <?php the_author() ?> @ <?php the_time() ?> <!--the_auhor()日志作者,the_time()日志发表时间--> <?php edit_post_link(__('Edit This')); ?> <!--edit_post_link()为日志的编辑链接,只有是管理员或作者的身份才会显示出来--> <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?> <!--comments_popup_link()为日志的评论--> </p> </div> </div> <?php endwhile; ?> <?php endif; ?> </body> |