wordpress主题制作

来源:互联网 发布:高中数学算法初步视频 编辑:程序博客网 时间:2024/04/29 07:19

1 基础知识

(1)必备的两个文件:index.php和style.css

(2)在index.php中的几个div标签:header(博客的头部)、content(一般式博客正文的列表)、sidebar(侧边栏,显示一些常用的功能)、footer(版权或友情链接等);

(3)一般将header、sidebar和footer三个div分别放在header.php,sidebar.php和footer.php三个文件中,然后用get_header(),get_sidebar和get_footer()三个函数调用,这样可以减少重复的代码,利于维护;

(4)single.php,archive.php,search.php,page.php四个文件分别对应不同的操作,如果没有这几个文件,就会调用index.php的样式。一般会在index.php上做一定的修改。

2、必备的wp函数

(1)blog_info($show=''):显示博客的信息,参数是个字符串

(2)have_posts() :循环中是否还有post(文章)

(3)the_post:循环列出post

一般这样用

<?php if(have_posts()):?><?php while(have_posts()):the_post();?><div class = "post" id="post-<?php the_ID();?>"> 。。。。。。<?php the_content();?>  。。。。。</div><?php endwhile;?><div class="navigation"><?php posts_nav_link();?></div><?php else:?>没有日志<?php endif;?>

(4)与日志有关的函数:the_permalink(),当前日志的永久链接;the_ID(),当前日志的ID;the_content($more_link_text = null, $stripteaser = false) :当前日志的内容。

(5)与日志的metadata有关的函数:the_category( $separator = '', $parents='', $post_id = false ),当前日志的分类;the_author( $deprecated = '', $deprecated_echo = true ),当前日志的作者;comments_popup_link,当前日志评论的显示方式等;edit_post_link,如果可编辑的话,会显示编辑。

(6)posts_nav_link:显示日志的导航,上一页,下一页;

(7)又侧边栏有关的函数:get_calendar,显示日历,有日志的能点击;wp_list_pages,显示页面Page,是指静态的页面;wp_list_categories,显示分类Categories;wp_get_archives,以特定的格式显示文章的分类,如月份;wp_list_bookmarks,显示所用的友情链接;wp_register,显示注册或管理;wp_loginout,显示登入或登出;wp_meta,响应meta动作。

(8)与动态侧边栏相关的函数。建立functions.php,代码如下

if ( function_exists('register_sidebar') )    register_sidebar();

在sidebar.php中加入以下代码:

<?php if(function_exists('dynamic_sidebar')&&dynamic_sidebar()):else:?> 。。。。。。。<!- 默认的侧边栏 -!><?php endif;?>

3、小提示

编辑php用zend studio挺好,编辑css文件还是用dreamweaver更快些。

   相关文档下载地址:http://download.csdn.net/detail/masofeng/4575077 


原创粉丝点击