网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 117.95.89.130
Old 2013-03-20, 02:38 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default 如何制作wordpress模板

有时候自己看到一个非常好的网站,但是没有模板。这个时候该怎么办呢?其实,在后知的这个博客的边栏是自己仿出来的,所以这里教大家如何用wp仿站制作模板,后知也是在学习中愿与大家一起学习制作。

首先,我们来进行对wordpress模板结构分析
索引页模版:index.php
顶部:header.php
文章页面模板:single.php
边栏模板:sidebar.php
底部:footer.php
页面模版:page.php
搜索结果:search.php
文章归档:archive.php
评论:comments.php
404 页面模版:404.php
主题支持函数:functions.php
样式表:style.css

然后,制作一个可以运行的wordpress主题,修改style.css
制作一个最简单的主题,只需要两个文件,index.php和style.css

第一步,准备静态页面
第二步,制作index.php和style.css
第三步,给style.css添加版权信息
第四步:把主题上传到空间中wordpress安装路径,wp-content/themes/下面,这里主题的文件夹名字必须是英文
第五步,在wordpress后台启用主题

先给style.css添加版权信息
/*
Theme Name: wordpress theme 01
Theme URI: Description: a simple bolg theme
Author: houzhi
Author URI: Version: 1.0
Tags: W*hite, blog, wangluoseo, blue
*/
所以的images都要换成<?php bloginfo('template_directory'); ?>/images
Style.css路径调用:<?php bloginfo( 'stylesheet_url' ); ?>
主题缩略图名字:screenshot.png

再制作出主题结构,index.php,header.php,footer.php,sidebar.php
把index.php拆分成header.php,footer.php和sidebar.phhp
<?php get_header();?>
<?php get_footer();?>
<?php get_sidebar();?>

还有就是,修改header.php,footer.php
新建一个index.php文件,header.php,footer.php,
这步需要用到的标签:
获取博客名字:<?php bloginfo('name'); ?>
获取博客描述:<?php bloginfo('description'); ?>
获取主页路径:<?php echo get_option('home'); ?>
获取主题存放路径:<?php bloginfo('template_directory'); ?>
其他外部文件调用方法:<?php include (TEMPLATEPATH . '/ad/ad2.htm'); ?>
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
<?php wp_head(); ?>
<title><?php if (is_home()||is_search()) { bloginfo('name'); } else { wp_title(''); print " - "; bloginfo('name'); } ?> </title>

页面调用:
<?php wp_list_pages('sort_column=menu_order&title_li=&depth=2&include='); ?>
分类目录调用:
<?php wp_list_categories('title_li=0&orderby=name&show_count=0&depth=2'); ?>

还有就是跟后知博客的边栏一样,制作sidebar.php
最新文章:<?php wp_get_archives('type=postbypost&limit=20'); ?>
日志标题太长超出,修改style.css,用到的代码:
text-overflow:ellipsis; W*hite-space:nowrap; overflow:hidden;
随机文章:
<?php rand_posts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;?>
标签云:
<?php wp_tag_cloud('smallest=8&largest=36&'); ?>
文章日期归档:
<?php wp_get_archives( 'type=monthly' ); ?>
分类目录:
<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
友情链接:
<?php wp_list_bookmarks('title_li=&categorize=0&orderby=rand&limit=24'); ?>

在进行对index.php的制作
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

标题:<a href="<?php the_permalink() ?>"><?php the_title_attribute(); ?></a>

调用文章内容:
<?php the_content("Read More..."); ?>
调用文章内容摘要:
<?php the_excerpt("Read More..."); ?>

作者:<?php the_author_posts_link(); ?>
日期:<?php the_time('F d, Y') ?>
评论调用:<?php comments_number('No Comment', '1 Comment', '% Comments' );?>
文章所属分类:标签:<?php the_category(', ') ?>
上一页,下一页调用:
<div style="float:left"><?php previous_post_link('&laquo; %link'); ?></div>
<div style="float:right"><?php next_post_link('%link &raquo;'); ?></div>

最后,制作single.php页面,加入评论
在single.php中调用<?php endwhile; ?>和<?php else : ?>中间让入
<?php comments_template(); ?>
这样就能够简单的制作出来一个模板了,后知愿与大家一起分享。(
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:54 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.